{
 "openapi": "3.1.0",
 "info": {
  "title": "PING API",
  "version": "v1",
  "description": "The PING fleet management API. Authenticate with an API key issued by the account owner: Authorization: Bearer ping_live_..."
 },
 "servers": [
  {
   "url": "{base}"
  }
 ],
 "security": [
  {
   "ApiKey": []
  }
 ],
 "paths": {
  "/v1/accessories": {
   "get": {
    "operationId": "listAccessories",
    "summary": "List approved accessories.",
    "description": "Cameras, sensors, beacons, CAN adapters, driver ID readers and cables, each with the tracker models it works with. Ordered by kind, then name.",
    "x-api-scope": "devices:read",
    "x-summary-ar": "قائمة الملحقات المعتمدة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of accessories.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AccessoryList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms": {
   "get": {
    "operationId": "listAlarms",
    "summary": "List alarms.",
    "description": "Alarms opened by the account's rules, newest first. A department-scoped key sees only alarms on its own vehicles.",
    "x-api-scope": "rules:read",
    "x-summary-ar": "قائمة التنبيهات.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     },
     {
      "name": "status",
      "in": "query",
      "description": "Only alarms in this status.",
      "schema": {
       "$ref": "#/components/schemas/AlarmStatus"
      }
     },
     {
      "name": "severity",
      "in": "query",
      "description": "Only alarms of this severity.",
      "schema": {
       "$ref": "#/components/schemas/Severity"
      }
     },
     {
      "name": "vehicle_id",
      "in": "query",
      "description": "Only alarms on this vehicle.",
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     {
      "name": "rule_id",
      "in": "query",
      "description": "Only alarms opened by this rule.",
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     },
     {
      "name": "kind",
      "in": "query",
      "description": "Only alarms of this kind (a template id, or custom).",
      "schema": {
       "$ref": "#/components/schemas/TemplateId"
      },
      "example": "overspeed"
     },
     {
      "name": "from",
      "in": "query",
      "description": "Only alarms seen at or after this time (their last occurrence).",
      "schema": {
       "type": "string",
       "format": "date-time"
      },
      "example": "2026-11-10T00:00:00Z"
     },
     {
      "name": "to",
      "in": "query",
      "description": "Only alarms opened before this time.",
      "schema": {
       "type": "string",
       "format": "date-time"
      },
      "example": "2026-11-17T00:00:00Z"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of alarms.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AlarmList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms/{alarmId}": {
   "get": {
    "operationId": "getAlarm",
    "summary": "Get an alarm.",
    "description": "One alarm with its lifecycle and its activity, oldest first: opened, repeated, acknowledged, assigned, commented, closed and reopened, with who and when.",
    "x-api-scope": "rules:read",
    "x-summary-ar": "بيانات تنبيه.",
    "parameters": [
     {
      "name": "alarmId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     }
    ],
    "responses": {
     "200": {
      "description": "The alarm.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AlarmDetail"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms/{alarmId}/ack": {
   "post": {
    "operationId": "ackAlarm",
    "summary": "Acknowledge an alarm.",
    "description": "Moves an open alarm to acked and records who acknowledged it and when, with an optional note. Any other status answers 409.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "تأكيد استلام تنبيه.",
    "parameters": [
     {
      "name": "alarmId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     }
    ],
    "requestBody": {
     "required": false,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlarmAck"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The alarm.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alarm"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms/{alarmId}/assign": {
   "post": {
    "operationId": "assignAlarm",
    "summary": "Assign an alarm to a user.",
    "description": "Gives an open or acked alarm to one of the account's users. An open alarm is acknowledged by the caller as it is assigned. A closed alarm answers 409.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "إسناد تنبيه إلى مستخدم.",
    "parameters": [
     {
      "name": "alarmId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlarmAssign"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The alarm.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alarm"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms/{alarmId}/close": {
   "post": {
    "operationId": "closeAlarm",
    "summary": "Close an alarm with a note.",
    "description": "Closes an open or acked alarm and records who closed it, when, the resolution (actioned or false positive) and the note. A closed alarm answers 409.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "إغلاق تنبيه مع ملاحظة.",
    "parameters": [
     {
      "name": "alarmId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlarmClose"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The alarm.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alarm"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms/{alarmId}/comments": {
   "post": {
    "operationId": "commentAlarm",
    "summary": "Add a note to an alarm.",
    "description": "Adds a note to the alarm's activity, whatever its status.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "إضافة ملاحظة إلى تنبيه.",
    "parameters": [
     {
      "name": "alarmId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     },
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/AlarmComment"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The activity entry.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AlarmActivity"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/alarms/{alarmId}/reopen": {
   "post": {
    "operationId": "reopenAlarm",
    "summary": "Reopen a closed alarm.",
    "description": "Puts a closed alarm back to open, unassigned and unacknowledged; its activity keeps what happened before. Any other status answers 409.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "إعادة فتح تنبيه مغلق.",
    "parameters": [
     {
      "name": "alarmId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     }
    ],
    "responses": {
     "200": {
      "description": "The alarm.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Alarm"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/coaching-sessions": {
   "get": {
    "operationId": "listCoachingSessions",
    "summary": "List coaching sessions",
    "description": "Coaching sessions held with the account's drivers, newest first; with driver, one driver's.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "جلسات توجيه السائقين",
    "parameters": [
     {
      "name": "driver",
      "in": "query",
      "description": "Only this driver's sessions",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of coaching sessions",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CoachingSessionList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createCoachingSession",
    "summary": "Record a coaching session",
    "description": "Records a coaching session with a driver: what it focused on, the score then, a note and when to follow up. The coach is the caller.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تسجيل جلسة توجيه",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CoachingSessionInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The session",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CoachingSession"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/commands/{commandId}": {
   "get": {
    "operationId": "getCommand",
    "summary": "Get a device command.",
    "description": "The state of a command sent to one of the account's trackers: queued, sent, acked, succeeded, failed or expired, with the device's reply.",
    "x-api-scope": "devices:read",
    "x-summary-ar": "حالة أمر الجهاز.",
    "parameters": [
     {
      "name": "commandId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     }
    ],
    "responses": {
     "200": {
      "description": "The command.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Command"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/contacts": {
   "get": {
    "operationId": "listContacts",
    "summary": "List messaging contacts.",
    "description": "Phone numbers that receive WhatsApp and SMS messages, with language and WhatsApp opt-in.",
    "x-api-scope": "accounts:read",
    "x-summary-ar": "قائمة جهات الاتصال للرسائل.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of contacts.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ContactList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "upsertContact",
    "summary": "Create or update a messaging contact.",
    "description": "Keyed by phone number: an existing contact with the same number is updated and answers 200, a new one 201.",
    "x-api-scope": "accounts:write",
    "x-summary-ar": "إنشاء جهة اتصال للرسائل أو تحديثها.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ContactInput"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The updated contact.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Contact"
        }
       }
      }
     },
     "201": {
      "description": "The new contact.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Contact"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/contacts/{contactId}": {
   "delete": {
    "operationId": "deleteContact",
    "summary": "Delete a messaging contact.",
    "description": "The number stops receiving the account's messages: the contact is removed and kept in the account's removed contacts with its opt-in and opt-out as they were (listRemovedContacts), and contact.changed is published with the opt-in withdrawn, so messaging records the number's opt-out. A user's verified phone is removed with its contact; the user verifies it again to be reached on WhatsApp.",
    "x-api-scope": "accounts:write",
    "x-summary-ar": "حذف جهة اتصال للرسائل.",
    "parameters": [
     {
      "name": "contactId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "responses": {
     "200": {
      "description": "The contact removed.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RemovedContact"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/customers/{customerId}": {
   "get": {
    "operationId": "getCustomer",
    "summary": "Get the account.",
    "description": "The account the API key belongs to. Any other customer id answers 404.",
    "x-api-scope": "accounts:read",
    "x-summary-ar": "بيانات الحساب.",
    "parameters": [
     {
      "name": "customerId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     }
    ],
    "responses": {
     "200": {
      "description": "The account.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Customer"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/departments": {
   "get": {
    "operationId": "listDepartments",
    "summary": "List departments.",
    "description": "The account's departments, each with its parent, so the tree can be rebuilt. Ordered by creation.",
    "x-api-scope": "accounts:read",
    "x-summary-ar": "قائمة الأقسام.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of departments.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DepartmentList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createDepartment",
    "summary": "Create a department.",
    "description": "A department at the top of the tree, or under parent_id.",
    "x-api-scope": "accounts:write",
    "x-summary-ar": "إنشاء قسم.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DepartmentInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The department.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Department"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/devices/{imei}/health": {
   "get": {
    "operationId": "getDeviceHealth",
    "summary": "Get a device's health.",
    "description": "Model, firmware, configuration profile, SIM and the latest reported connectivity, power and GNSS state of a device installed in one of the account's vehicles. A device not installed in a vehicle the key can see answers 404.",
    "x-api-scope": "devices:read",
    "x-summary-ar": "حالة الجهاز.",
    "parameters": [
     {
      "name": "imei",
      "in": "path",
      "required": true,
      "description": "The device's 15-digit IMEI.",
      "schema": {
       "$ref": "#/components/schemas/FieldImei"
      },
      "example": "356307042441013"
     }
    ],
    "responses": {
     "200": {
      "description": "The device's health.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DeviceHealth"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/drivers": {
   "get": {
    "operationId": "listDrivers",
    "summary": "List drivers",
    "description": "Lists the account's drivers by name.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض قائمة السائقين",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     },
     {
      "name": "left",
      "in": "query",
      "description": "true lists the drivers who have left instead.",
      "schema": {
       "type": "boolean",
       "default": false
      }
     }
    ],
    "responses": {
     "200": {
      "description": "A page of drivers",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DriverList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createDriver",
    "summary": "Create a driver",
    "description": "Registers a driver with a WhatsApp number for job links, the ID or Iqama their licence is issued on, the licence's classes and expiry, and an iButton key for identification (driver.changed).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إضافة سائق",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DriverInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The driver",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Driver"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/drivers/{driverId}": {
   "get": {
    "operationId": "getDriver",
    "summary": "Get a driver",
    "description": "Returns one driver, in the account or having left it.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض بيانات سائق",
    "parameters": [
     {
      "$ref": "#/components/parameters/DriverId"
     }
    ],
    "responses": {
     "200": {
      "description": "The driver",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Driver"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/DriverBadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "patch": {
    "operationId": "updateDriver",
    "summary": "Update a driver",
    "description": "Changes the fields sent; a field sent as null is cleared. The name cannot be cleared; licence_classes sent replaces the classes held.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعديل بيانات سائق",
    "parameters": [
     {
      "$ref": "#/components/parameters/DriverId"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DriverUpdate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The driver",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Driver"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/drivers/{driverId}/leave": {
   "post": {
    "operationId": "leaveDriver",
    "summary": "Record a driver leaving",
    "description": "The driver leaves the account on the date given: their record and history stay, their open driver session ends, and they move to the former drivers.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تسجيل مغادرة سائق",
    "parameters": [
     {
      "$ref": "#/components/parameters/DriverId"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/LeaveInput"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The driver",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Driver"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/driving-scores": {
   "get": {
    "operationId": "getDrivingScores",
    "summary": "Get each vehicle's or driver's driving score over a period.",
    "description": "Distance, driving and idle time, harsh driving and overspeeding events, and a 0 to 100 score per vehicle (or per driver with `by=driver`), over the Riyadh calendar days from `from` to `to` inclusive, at most 92 days, or per Riyadh week (Sunday first) with `per=week`. Without dates, the last 7 days. Trips count by their start; events count with the trip they happened in. A trip's driver is the driver whose iButton key or card the device read, else the driver assigned to the vehicle when it started.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "تقييم القيادة لكل مركبة خلال فترة.",
    "parameters": [
     {
      "name": "from",
      "in": "query",
      "description": "First day (Riyadh), YYYY-MM-DD.",
      "schema": {
       "type": "string",
       "format": "date"
      },
      "example": "2026-11-01"
     },
     {
      "name": "to",
      "in": "query",
      "description": "Last day (Riyadh), YYYY-MM-DD, inclusive.",
      "schema": {
       "type": "string",
       "format": "date"
      },
      "example": "2026-11-07"
     },
     {
      "name": "by",
      "in": "query",
      "description": "Score each vehicle (default) or each driver.",
      "schema": {
       "type": "string",
       "enum": [
        "vehicle",
        "driver"
       ],
       "default": "vehicle"
      },
      "example": "driver"
     },
     {
      "name": "per",
      "in": "query",
      "description": "One score over the whole period (default) or one per week.",
      "schema": {
       "type": "string",
       "enum": [
        "period",
        "week"
       ],
       "default": "period"
      },
      "example": "week"
     }
    ],
    "responses": {
     "200": {
      "description": "Driving scores.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DrivingScores"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/geofences": {
   "get": {
    "operationId": "listGeofences",
    "summary": "List geofences",
    "description": "Lists the account's geofences by name, each as a GeoJSON polygon or a circle (a point with radius_m).",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض المناطق الجغرافية",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of geofences",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/GeofenceList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createGeofence",
    "summary": "Create a geofence",
    "description": "Creates a circle (a GeoJSON Point and radius_m) or a GeoJSON Polygon, in WGS 84 longitude and latitude (geofence.changed).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إنشاء منطقة جغرافية",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/GeofenceInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The geofence",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Geofence"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/geofences/{geofenceId}": {
   "patch": {
    "operationId": "updateGeofence",
    "summary": "Update a geofence",
    "description": "Changes the fields sent. A new geometry replaces the shape; radius_m alone resizes a circle; a cargo bound sent as null is cleared.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعديل منطقة جغرافية",
    "parameters": [
     {
      "$ref": "#/components/parameters/GeofenceId"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/GeofenceUpdate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The geofence",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Geofence"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "deleteGeofence",
    "summary": "Delete a geofence",
    "description": "Deletes the geofence permanently; stops picked from it keep their place and lose the link.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "حذف منطقة جغرافية",
    "parameters": [
     {
      "$ref": "#/components/parameters/GeofenceId"
     }
    ],
    "responses": {
     "204": {
      "description": "Deleted"
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/groups": {
   "get": {
    "operationId": "listGroups",
    "summary": "List vehicle groups",
    "description": "Lists the account's vehicle groups by name with their vehicles. A department-scoped key sees only its vehicles in each group.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض مجموعات المركبات",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of groups",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/GroupList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createGroup",
    "summary": "Create a vehicle group",
    "description": "Creates a named group of the account's vehicles.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إنشاء مجموعة مركبات",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/GroupInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The group",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Group"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/groups/{groupId}": {
   "patch": {
    "operationId": "updateGroup",
    "summary": "Change a vehicle group",
    "description": "Renames the group, and adds or removes vehicles (a vehicle both added and removed is refused). A department-scoped key changes only its own vehicles in it.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعديل مجموعة مركبات",
    "parameters": [
     {
      "name": "groupId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-be6f-7071-c28d-9e0f1a2b3c4d"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/GroupPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The group",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Group"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "deleteGroup",
    "summary": "Delete a vehicle group",
    "description": "Deletes the group; its vehicles are not changed. A department-scoped key deletes only a group holding none but its own vehicles.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "حذف مجموعة مركبات",
    "parameters": [
     {
      "name": "groupId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-be6f-7071-c28d-9e0f1a2b3c4d"
     }
    ],
    "responses": {
     "200": {
      "description": "The group deleted, as it was",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Group"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/jobs": {
   "get": {
    "operationId": "listJobs",
    "summary": "List jobs",
    "description": "Lists jobs, latest scheduled first, filtered by status, vehicle and day (Asia/Riyadh). A department-scoped key sees jobs of its vehicles and jobs without a vehicle.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض المهام",
    "parameters": [
     {
      "name": "status",
      "in": "query",
      "description": "Only jobs in this status",
      "schema": {
       "$ref": "#/components/schemas/JobStatus"
      }
     },
     {
      "name": "vehicle",
      "in": "query",
      "description": "Only jobs of this vehicle",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "day",
      "in": "query",
      "description": "Only jobs scheduled (or, unscheduled, created) on this day in Asia/Riyadh",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "cold",
      "in": "query",
      "description": "Only jobs that carry a cold-chain load (a cargo temperature range)",
      "schema": {
       "type": "boolean"
      }
     },
     {
      "name": "from",
      "in": "query",
      "description": "Only jobs not finished (completed, failed or cancelled) before this time",
      "schema": {
       "type": "string",
       "format": "date-time"
      }
     },
     {
      "name": "to",
      "in": "query",
      "description": "Only jobs started (or, not started, scheduled or created) before this time",
      "schema": {
       "type": "string",
       "format": "date-time"
      }
     },
     {
      "name": "department",
      "in": "query",
      "description": "Only jobs planned for this department, or on its vehicles",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "with_stops",
      "in": "query",
      "description": "Include each job's stops",
      "schema": {
       "type": "boolean"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of jobs",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/JobList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createJob",
    "summary": "Create a job",
    "description": "Creates a draft job with its stops in order, the proof each stop needs, and optionally its vehicle, driver and cargo temperature range.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إنشاء مهمة",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/JobInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The job",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Job"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/jobs/{jobId}": {
   "get": {
    "operationId": "getJob",
    "summary": "Get a job",
    "description": "Returns a job with its stops, its event history and the proofs collected at each stop.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض تفاصيل مهمة",
    "parameters": [
     {
      "$ref": "#/components/parameters/JobId"
     }
    ],
    "responses": {
     "200": {
      "description": "The job",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Job"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/jobs/{jobId}/cancel": {
   "post": {
    "operationId": "cancelJob",
    "summary": "Cancel a job",
    "description": "Cancels a job that has not finished and revokes its tracking links (job.cancelled).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إلغاء مهمة",
    "parameters": [
     {
      "name": "jobId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-9c4d-7e5f-a06b-7c8d9e0f1a2b"
     }
    ],
    "responses": {
     "200": {
      "description": "The cancelled job",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Job"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/jobs/{jobId}/dispatch": {
   "post": {
    "operationId": "dispatchJob",
    "summary": "Dispatch a job",
    "description": "Sends a draft job to its driver by WhatsApp link and each stop's contact a tracking link (job.dispatched). The job needs a vehicle; the driver defaults to the vehicle's current driver.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إرسال مهمة إلى السائق",
    "parameters": [
     {
      "name": "jobId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-9c4d-7e5f-a06b-7c8d9e0f1a2b"
     }
    ],
    "responses": {
     "200": {
      "description": "The dispatched job and the driver's link",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DispatchedJob"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/media/{mediaId}/file": {
   "get": {
    "operationId": "getMediaFile",
    "summary": "Download a photo or clip.",
    "description": "The photo (JPEG) or clip (MP4) itself, for an account that owned the vehicle when it was taken. A file not yet received answers 404.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "تنزيل صورة أو مقطع.",
    "parameters": [
     {
      "name": "mediaId",
      "in": "path",
      "required": true,
      "schema": {
       "$ref": "#/components/schemas/Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The file.",
      "content": {
       "image/jpeg": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       },
       "video/mp4": {
        "schema": {
         "type": "string",
         "format": "binary"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/models": {
   "get": {
    "operationId": "listModels",
    "summary": "List approved tracker models.",
    "description": "Every tracker model PING installs, with its datasheet, media and the manufacturer's product page. Ordered by name.",
    "x-api-scope": "devices:read",
    "x-summary-ar": "قائمة طرازات أجهزة التتبع المعتمدة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of models.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ModelList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/models/{model}": {
   "get": {
    "operationId": "getModel",
    "summary": "Get a tracker model.",
    "description": "One approved tracker model by name, with its datasheet, media and product page.",
    "x-api-scope": "devices:read",
    "x-summary-ar": "بيانات طراز جهاز التتبع.",
    "parameters": [
     {
      "name": "model",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 1,
       "maxLength": 60
      },
      "example": "FMC130"
     }
    ],
    "responses": {
     "200": {
      "description": "The model.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Model"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/positions/last": {
   "get": {
    "operationId": "getLastPositions",
    "summary": "Get the last known position of each vehicle.",
    "description": "The latest position and state of every vehicle the account owns now, from the device installed in it. Vehicles with no position since their device was installed are left out. Ordered by vehicle id.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "آخر موقع معروف لكل مركبة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of last positions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/LastPositionList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/removed-contacts": {
   "get": {
    "operationId": "listRemovedContacts",
    "summary": "List removed messaging contacts.",
    "description": "Contacts deleted from the account, newest first, each with its opt-in and opt-out as they stood when it was removed, and who removed it.",
    "x-api-scope": "accounts:read",
    "x-summary-ar": "قائمة جهات الاتصال المحذوفة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of removed contacts.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RemovedContactList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/reports": {
   "post": {
    "operationId": "sendReport",
    "summary": "Send a fleet report.",
    "description": "Queues a fleet summary, trips, alarms or daily statistics report for a period, rendered as PDF or Excel and sent by email or WhatsApp to the recipients given. The response is the queued request; rendering and delivery follow asynchronously.",
    "x-api-scope": "reports:write",
    "x-summary-ar": "إرسال تقرير الأسطول.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ReportInput"
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "The queued report request.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ReportRequest"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/rider-runs": {
   "get": {
    "operationId": "listRiderRuns",
    "summary": "List rider runs",
    "description": "Lists the vehicles' trips that had card taps, latest first, over one day or a range of days (Asia/Riyadh; at most [service.riders] max_days, 31, per call): the first and last tap, the cards nobody holds, and each rider with when they boarded and when they got off after their last board (null when the trip's taps end with them on board).",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض رحلات الركاب",
    "parameters": [
     {
      "name": "vehicle",
      "in": "query",
      "description": "Only this vehicle's runs",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "day",
      "in": "query",
      "description": "Runs with taps on this day in Asia/Riyadh (or from and to)",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "from",
      "in": "query",
      "description": "Runs with taps on or after this day in Asia/Riyadh",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "description": "Runs with taps on or before this day in Asia/Riyadh (defaults to from)",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of runs",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RiderRunList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/rider-taps": {
   "get": {
    "operationId": "listRiderTaps",
    "summary": "List rider card taps",
    "description": "Lists card taps on vehicles, latest first, filtered by vehicle, rider and one day or a range of days (Asia/Riyadh; at most [service.riders] max_days, 31, per call): who boarded, who alighted, and cards nobody holds.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض سجل صعود الركاب ونزولهم",
    "parameters": [
     {
      "name": "vehicle",
      "in": "query",
      "description": "Only taps on this vehicle",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "day",
      "in": "query",
      "description": "Only taps on this day in Asia/Riyadh (not with from and to)",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "rider",
      "in": "query",
      "description": "Only this rider's taps",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "from",
      "in": "query",
      "description": "Only taps on or after this day in Asia/Riyadh",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "name": "to",
      "in": "query",
      "description": "Only taps on or before this day in Asia/Riyadh (defaults to from)",
      "schema": {
       "type": "string",
       "format": "date"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of taps",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RiderTapList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/riders": {
   "get": {
    "operationId": "listRiders",
    "summary": "List riders",
    "description": "Lists riders (students) by name with their cards and guardians.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض قائمة الركاب",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of riders",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RiderList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createRider",
    "summary": "Create a rider",
    "description": "Adds a rider with the card they tap on the vehicle, their route and the guardians notified when they board and alight.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إضافة راكب",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RiderInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The rider",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Rider"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/riders/{riderId}": {
   "patch": {
    "operationId": "updateRider",
    "summary": "Update a rider",
    "description": "Changes a rider's name, card (a replaced card), route, guardians (the list sent replaces the list held) or whether they still ride (active false: their card then taps as unknown).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعديل بيانات راكب",
    "parameters": [
     {
      "name": "riderId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-cf70-7182-d39e-0f1a2b3c4d5e"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RiderPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The rider",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Rider"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/routes": {
   "get": {
    "operationId": "listRoutes",
    "summary": "List saved routes",
    "description": "Lists saved routes by name, such as a school run or a regular delivery round, with their stops. A department-scoped key sees routes of its vehicles and routes without a vehicle.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض المسارات المحفوظة",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of routes",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RouteList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createRoute",
    "summary": "Save a route",
    "description": "Saves a route's stops, and optionally its vehicle and driver, to run as a job on demand.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "حفظ مسار",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RouteInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The route",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Route"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/routes/{routeId}": {
   "patch": {
    "operationId": "updateRoute",
    "summary": "Change a saved route",
    "description": "Renames the route, sets or clears its vehicle and driver, or replaces its stops (in the order given). Jobs already made from it are not changed.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعديل مسار محفوظ",
    "parameters": [
     {
      "name": "routeId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-be6f-7071-c28d-9e0f1a2b3c4d"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RoutePatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The route",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Route"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "deleteRoute",
    "summary": "Delete a saved route",
    "description": "Only while no active rider rides it (409, code route_has_riders: move them or end their riding first). Jobs made from it and riders who left it keep their history without it.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "حذف مسار محفوظ",
    "parameters": [
     {
      "name": "routeId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-be6f-7071-c28d-9e0f1a2b3c4d"
     }
    ],
    "responses": {
     "200": {
      "description": "The route deleted, as it was",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Route"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/routes/{routeId}/run": {
   "post": {
    "operationId": "runRoute",
    "summary": "Create a job from a saved route",
    "description": "Creates a draft job from the route's stops, vehicle and driver, scheduled now or at scheduled_at, and dispatches it when dispatch is true.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إنشاء مهمة من مسار محفوظ",
    "parameters": [
     {
      "name": "routeId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-be6f-7071-c28d-9e0f1a2b3c4d"
     },
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RouteRun"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The job",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DispatchedJob"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/rules": {
   "get": {
    "operationId": "listRules",
    "summary": "List alert rules.",
    "description": "The account's alert rules, oldest first. A department-scoped key sees only the rules on its own vehicles.",
    "x-api-scope": "rules:read",
    "x-summary-ar": "قائمة قواعد التنبيه.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     },
     {
      "name": "template",
      "in": "query",
      "description": "Only rules made from this template; custom for custom rules.",
      "schema": {
       "$ref": "#/components/schemas/TemplateId"
      },
      "example": "overspeed"
     },
     {
      "name": "enabled",
      "in": "query",
      "description": "Only enabled (true) or disabled (false) rules.",
      "schema": {
       "type": "boolean"
      }
     },
     {
      "name": "geofence_id",
      "in": "query",
      "description": "Only the rules scoped to this geofence.",
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of rules.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RuleList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createRule",
    "summary": "Create an alert rule.",
    "description": "A rule from a built-in template with optional overrides (its parameters typed by the template's catalog), or a custom declarative definition, applied to the whole account, a department (group), one vehicle or one geofence. Give template or definition, not both. A department-scoped key creates rules only on its own vehicles.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "إنشاء قاعدة تنبيه.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RuleInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The rule.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Rule"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/rules/{ruleId}": {
   "patch": {
    "operationId": "updateRule",
    "summary": "Update an alert rule.",
    "description": "Changes the fields given and keeps the rest. overrides applies to template rules and definition to custom rules; each replaces the stored value whole. An empty name clears the name; scope_kind and scope_id change together.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "تعديل قاعدة تنبيه.",
    "parameters": [
     {
      "name": "ruleId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RuleUpdate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The rule.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Rule"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "deleteRule",
    "summary": "Delete an alert rule.",
    "description": "The rule stops evaluating. Alarms it opened remain, with rule_id set to null.",
    "x-api-scope": "rules:write",
    "x-summary-ar": "حذف قاعدة تنبيه.",
    "parameters": [
     {
      "name": "ruleId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     }
    ],
    "responses": {
     "204": {
      "description": "Deleted."
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/users": {
   "get": {
    "operationId": "listUsers",
    "summary": "List users.",
    "description": "The account's users with their role, data scope and language. Ordered by creation.",
    "x-api-scope": "accounts:read",
    "x-summary-ar": "قائمة المستخدمين.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     },
     {
      "name": "deactivated",
      "in": "query",
      "description": "true: the deactivated users instead of the active ones.",
      "schema": {
       "type": "boolean",
       "default": false
      }
     }
    ],
    "responses": {
     "200": {
      "description": "A page of users.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/UserList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "inviteUser",
    "summary": "Invite a user.",
    "description": "Adds a user to the account with a role and data scope. The invitation is sent to the email or phone given.",
    "x-api-scope": "accounts:write",
    "x-summary-ar": "دعوة مستخدم.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/UserInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The user.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/User"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/users/{userId}/role": {
   "patch": {
    "operationId": "updateUserRole",
    "summary": "Change a user's role and data scope.",
    "description": "The account always keeps at least one owner: demoting the last owner answers 409.",
    "x-api-scope": "accounts:write",
    "x-summary-ar": "تغيير دور المستخدم ونطاق بياناته.",
    "parameters": [
     {
      "name": "userId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e70"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RoleInput"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The user.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/User"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicle-requests": {
   "post": {
    "operationId": "requestVehicleChange",
    "summary": "Ask PING to change a vehicle's registration, or to add a vehicle",
    "description": "A vehicle's registered fields (plate, VIN, kind, use, make, model, year) are PING's (ADR 32). kind change asks for the fields given in fields (only those, each kept with its value now; null clears one but the plate and use); kind add asks for a vehicle with no unit (papers only), every registered field given. A justification is required; 0 to 3 supporting files (PDF, JPEG or PNG, base64, limits in fleet's unit.toml [service.requests]). One request waits per vehicle (409). PING's staff approve it, applying every field at once, or reject it with a reason; the asker and the owners are told (vehicle_request.decided). A department-scoped caller asks only for its departments' vehicles, and adds one only into one of its departments.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "طلب تعديل بيانات تسجيل مركبة أو إضافة مركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/VehicleRequestInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The request, pending",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleRequest"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "get": {
    "operationId": "listVehicleRequests",
    "summary": "List the account's vehicle requests",
    "description": "Newest first; with vehicle_id one vehicle's, with state only those in it. A department-scoped key sees its own vehicles' requests and the additions into its departments.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض طلبات المركبات",
    "parameters": [
     {
      "name": "vehicle_id",
      "in": "query",
      "description": "One vehicle's requests.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "state",
      "in": "query",
      "description": "Only requests in this state.",
      "schema": {
       "$ref": "#/components/schemas/VehicleRequestState"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of requests",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleRequestList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicle-requests/{requestId}": {
   "get": {
    "operationId": "getVehicleRequest",
    "summary": "Get a vehicle request",
    "description": "The fields asked with their values when asked, the justification, the files sent (named, not read back) and the decision.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض طلب مركبة",
    "parameters": [
     {
      "name": "requestId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9e"
     }
    ],
    "responses": {
     "200": {
      "description": "The request",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleRequest"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicle-requests/{requestId}/withdraw": {
   "post": {
    "operationId": "withdrawVehicleRequest",
    "summary": "Withdraw a pending vehicle request",
    "description": "Only while pending (409 otherwise).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "سحب طلب مركبة",
    "parameters": [
     {
      "name": "requestId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9e"
     }
    ],
    "responses": {
     "200": {
      "description": "The request, withdrawn",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleRequest"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles": {
   "get": {
    "operationId": "listVehicles",
    "summary": "List vehicles",
    "description": "Lists the account's vehicles by plate: those in service, or with retired=true those taken out of service; plate_code and vin narrow it to those vehicles. A department-scoped key sees only its departments' vehicles.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض قائمة المركبات",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     },
     {
      "name": "retired",
      "in": "query",
      "description": "true lists the vehicles taken out of service instead.",
      "schema": {
       "type": "boolean",
       "default": false
      }
     },
     {
      "name": "plate_code",
      "in": "query",
      "description": "Only the vehicles with these plates (up to 200; indexed).",
      "style": "form",
      "explode": true,
      "schema": {
       "type": "array",
       "maxItems": 200,
       "items": {
        "$ref": "#/components/schemas/FieldPlate"
       }
      }
     },
     {
      "name": "vin",
      "in": "query",
      "description": "Only the vehicle with this VIN (indexed).",
      "schema": {
       "$ref": "#/components/schemas/FieldVin"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "A page of vehicles",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}": {
   "get": {
    "operationId": "getVehicle",
    "summary": "Get a vehicle",
    "description": "Returns one vehicle with its current driver.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "عرض بيانات مركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     }
    ],
    "responses": {
     "200": {
      "description": "The vehicle",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Vehicle"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "patch": {
    "operationId": "updateVehicle",
    "summary": "Update a vehicle's operational fields",
    "description": "Changes the operational fields sent (fleet number, department, speed limit, cargo range, tank, pallets, fuel type); a field sent as null is cleared. Each changed field is a history entry (a department move its own kind). The registered fields (plate, VIN, kind, use, make, model, year) are PING's: one in the body answers 400 naming requestVehicleChange, which asks PING to change them.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعديل بيانات مركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/VehicleUpdate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The vehicle",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Vehicle"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/daily-stats": {
   "get": {
    "operationId": "getDailyStats",
    "summary": "Get a vehicle's daily distance, driving, idle and engine time, events and fuel.",
    "description": "One entry per day with data, by the Riyadh calendar day (UTC+3), from `from` to `to` inclusive, at most 92 days. Without them, the last 7 days.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "المسافة اليومية للمركبة وزمن القيادة والتباطؤ وتشغيل المحرك.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "name": "from",
      "in": "query",
      "description": "First day (Riyadh), YYYY-MM-DD.",
      "schema": {
       "type": "string",
       "format": "date"
      },
      "example": "2026-11-01"
     },
     {
      "name": "to",
      "in": "query",
      "description": "Last day (Riyadh), YYYY-MM-DD, inclusive.",
      "schema": {
       "type": "string",
       "format": "date"
      },
      "example": "2026-11-07"
     }
    ],
    "responses": {
     "200": {
      "description": "The vehicle's daily statistics.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DailyStats"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/documents": {
   "get": {
    "operationId": "getVehicleDocuments",
    "summary": "List a vehicle's documents",
    "description": "The vehicle's papers: Istimara, operating card, insurance and periodic inspection (FAHAS), each with its number and dates. A paper not recorded yet is left out.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "وثائق المركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     }
    ],
    "responses": {
     "200": {
      "description": "The vehicle's documents",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleDocuments"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/documents/{type}": {
   "put": {
    "operationId": "putVehicleDocument",
    "summary": "Record a vehicle document",
    "description": "Records or replaces one paper by its type (the operating card's number is TGA's). Recorded in the vehicle's history.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تسجيل وثيقة مركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "name": "type",
      "in": "path",
      "required": true,
      "schema": {
       "$ref": "#/components/schemas/VehicleDocumentType"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/VehicleDocumentInput"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The document",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleDocument"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "deleteVehicleDocument",
    "summary": "Delete a vehicle document recorded by mistake",
    "description": "Removes the paper of this type; the vehicle's history keeps it (kind document_deleted: its type, number and expiry, and the reason given).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "حذف وثيقة مركبة سُجّلت خطأً",
    "parameters": [
     {
      "name": "vehicleId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-be6f-7071-c28d-9e0f1a2b3c4d"
     },
     {
      "name": "type",
      "in": "path",
      "required": true,
      "schema": {
       "$ref": "#/components/schemas/VehicleDocumentType"
      }
     },
     {
      "name": "reason",
      "in": "query",
      "description": "Why it is deleted (kept in the history)",
      "schema": {
       "type": "string",
       "minLength": 3,
       "maxLength": 200
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The document deleted, as it was",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleDocument"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/driver": {
   "post": {
    "operationId": "assignDriver",
    "summary": "Assign a driver to a vehicle",
    "description": "Starts a manual driver session on the vehicle. It ends the vehicle's open session and the driver's open session on any other vehicle (driver.session_changed for each).",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "تعيين سائق لمركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DriverAssignment"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The driver session",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DriverSession"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "unassignDriver",
    "summary": "End the vehicle's driver session",
    "description": "Ends the vehicle's open driver session, so no driver is assigned to it. A vehicle with no driver answers 204 as well.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إنهاء تعيين سائق المركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     }
    ],
    "responses": {
     "204": {
      "description": "No driver is assigned to the vehicle."
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/fuel-events": {
   "get": {
    "operationId": "getFuelEvents",
    "summary": "Get a vehicle's refuels and fuel drops.",
    "description": "Refuels and drops found in the tank level: a rise or a fall past the thresholds (services/telemetry/unit.toml [service.fuel]) while the vehicle stands, newest first. Without from and to, the last 7 days; at most 31 days.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "التزود بالوقود وانخفاضاته للمركبة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/From"
     },
     {
      "$ref": "#/components/parameters/To"
     }
    ],
    "responses": {
     "200": {
      "description": "The vehicle's fuel events.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/FuelEvents"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/history": {
   "get": {
    "operationId": "listVehicleHistory",
    "summary": "List a vehicle's history",
    "description": "What happened to the vehicle in the account, newest first: registered, a field changed, department changed, driver assigned, a document recorded, retired. Append-only.",
    "x-api-scope": "fleet:read",
    "x-summary-ar": "سجل المركبة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of history entries",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/VehicleHistoryList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/immobilizer": {
   "post": {
    "operationId": "setImmobilizer",
    "summary": "Cut or restore a vehicle's engine.",
    "description": "Queues a command to the vehicle's tracker that switches its immobilizer output. A cut is accepted only while the vehicle is stationary with the ignition off, from a state reported within the last few minutes; a restore is always accepted and waits up to two of a parked unit's sends for it to connect. Follow the command with getCommand.",
    "x-risk": [
     "device-control"
    ],
    "x-api-scope": "devices:control",
    "x-summary-ar": "إيقاف محرك المركبة أو إعادة تشغيله.",
    "parameters": [
     {
      "name": "vehicleId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ImmobilizerInput"
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "The queued command.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Command"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     },
     "503": {
      "description": "The vehicle's current speed and ignition are unavailable, so the safety checks cannot run (code: unavailable). Nothing was queued.",
      "content": {
       "application/problem+json": {
        "schema": {
         "$ref": "#/components/schemas/Problem"
        }
       }
      }
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/media": {
   "get": {
    "operationId": "listVehicleMedia",
    "summary": "List photos and clips from a vehicle's cameras.",
    "description": "Photos and clips from the vehicle's cameras (FMC650 with DualCam or DashCam), newest first, with what triggered them and their status. Download a stored file with getMediaFile.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "قائمة الصور والمقاطع من كاميرات المركبة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/From"
     },
     {
      "$ref": "#/components/parameters/To"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of media.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MediaList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/retire": {
   "post": {
    "operationId": "retireVehicle",
    "summary": "Take a vehicle out of service",
    "description": "Retires the vehicle with a reason: it leaves the register and the live map, keeps its history and data, and ends its open driver session.",
    "x-api-scope": "fleet:write",
    "x-summary-ar": "إخراج مركبة من الخدمة",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RetireInput"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The retired vehicle",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Vehicle"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/signals/{key}": {
   "get": {
    "operationId": "getSignalSeries",
    "summary": "Get the history of one vehicle signal.",
    "description": "One measurement signal (fuel_level_pct, external_voltage_v, cargo_temp_c ...) between two times, averaged per step (default 300 s), oldest first, at most 7 days per request.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "سجل قراءة من قراءات المركبة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "name": "key",
      "in": "path",
      "required": true,
      "description": "The measurement signal (infra/devices/io/signals.toml).",
      "schema": {
       "$ref": "#/components/schemas/SignalKey"
      }
     },
     {
      "$ref": "#/components/parameters/FromRequired"
     },
     {
      "$ref": "#/components/parameters/ToRequired"
     },
     {
      "name": "step",
      "in": "query",
      "description": "Seconds per point, 60 to 3600.",
      "schema": {
       "type": "integer",
       "minimum": 60,
       "maximum": 3600,
       "default": 300
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The signal's history.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/SignalSeries"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/stops": {
   "get": {
    "operationId": "listStops",
    "summary": "List a vehicle's stops in a period.",
    "description": "Stops that start in the period, newest first, with their duration, location and idling time. Without `from` and `to`, the last 7 days.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "توقفات المركبة خلال فترة مع مدتها وموقعها.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/From"
     },
     {
      "$ref": "#/components/parameters/To"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of stops.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/StopList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/timeline": {
   "get": {
    "operationId": "getVehicleTimeline",
    "summary": "Get a vehicle's timeline of ignition, motion, trips, stops, driving events and connectivity.",
    "description": "Ignition and motion changes, trip and stop boundaries, harsh driving, overspeeding, crash, towing, jamming and power-cut events, and device connections in one time-ordered list, at most 24 hours per request. Alarms are read with the rules API.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "السجل الزمني للمركبة: الإشعال والحركة والرحلات والتوقفات والاتصال.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/FromRequired"
     },
     {
      "$ref": "#/components/parameters/ToRequired"
     }
    ],
    "responses": {
     "200": {
      "description": "The vehicle's timeline.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Timeline"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/track": {
   "get": {
    "operationId": "getTrack",
    "summary": "Get a vehicle's track between two times.",
    "description": "The vehicle's positions from `from` (inclusive) to `to` (exclusive), oldest first, at most 7 days per request. Positions flagged as invalid (no fix or an impossible jump) are kept with valid = false.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "مسار المركبة بين وقتين.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/FromRequired"
     },
     {
      "$ref": "#/components/parameters/ToRequired"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of positions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TrackList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/vehicles/{vehicleId}/trips": {
   "get": {
    "operationId": "listTrips",
    "summary": "List a vehicle's trips in a period.",
    "description": "Trips that start in the period, newest first. A trip runs from ignition on and motion to the stop that ends it. Without `from` and `to`, the last 7 days.",
    "x-api-scope": "telemetry:read",
    "x-summary-ar": "رحلات المركبة خلال فترة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/VehicleId"
     },
     {
      "$ref": "#/components/parameters/From"
     },
     {
      "$ref": "#/components/parameters/To"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of trips.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TripList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-deliveries": {
   "get": {
    "operationId": "listWebhookDeliveries",
    "summary": "The account's webhook deliveries, newest first.",
    "description": "Deliveries are kept 30 days.",
    "x-api-scope": "webhooks:read",
    "x-summary-ar": "سجل تسليم الويب هوك.",
    "parameters": [
     {
      "name": "endpoint_id",
      "in": "query",
      "description": "One endpoint's deliveries.",
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
     },
     {
      "name": "state",
      "in": "query",
      "description": "Only deliveries in this state.",
      "schema": {
       "$ref": "#/components/schemas/WebhookDeliveryState"
      }
     },
     {
      "name": "type",
      "in": "query",
      "description": "Only deliveries of this event type.",
      "schema": {
       "$ref": "#/components/schemas/WebhookEventTypeOrTest"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of deliveries.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookDeliveryList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-deliveries/{deliveryId}": {
   "get": {
    "operationId": "getWebhookDelivery",
    "summary": "One delivery with every attempt.",
    "x-api-scope": "webhooks:read",
    "x-summary-ar": "تسليم ويب هوك مع محاولاته.",
    "parameters": [
     {
      "name": "deliveryId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d2-3c4d-7e5f-8a6b-7c8d9e0f1a2b"
     }
    ],
    "responses": {
     "200": {
      "description": "The delivery.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookDeliveryDetail"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-deliveries/{deliveryId}/redeliver": {
   "post": {
    "operationId": "redeliverWebhook",
    "summary": "Send a finished delivery's event to its endpoint again, as a new delivery (same event id).",
    "description": "Only a delivery that succeeded or failed, to an enabled endpoint (else 409).",
    "x-api-scope": "webhooks:write",
    "x-risk": [
     "data-sharing"
    ],
    "x-summary-ar": "إعادة إرسال حدث ويب هوك.",
    "parameters": [
     {
      "name": "deliveryId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d2-3c4d-7e5f-8a6b-7c8d9e0f1a2b"
     }
    ],
    "responses": {
     "202": {
      "description": "The new delivery, queued.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookDelivery"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-endpoints": {
   "get": {
    "operationId": "listWebhookEndpoints",
    "summary": "List the account's webhook endpoints, oldest first.",
    "x-api-scope": "webhooks:read",
    "x-summary-ar": "قائمة نقاط استقبال الويب هوك.",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Cursor"
     }
    ],
    "responses": {
     "200": {
      "description": "A page of endpoints.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookEndpointList"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "post": {
    "operationId": "createWebhookEndpoint",
    "summary": "Add a webhook endpoint: an https URL and the event types it receives. Its signing secret is answered once.",
    "description": "The URL must be https and its host a name or a public address (private, loopback, link-local and reserved addresses are refused, and checked again on every delivery). At most 10 endpoints per account.",
    "x-api-scope": "webhooks:write",
    "x-risk": [
     "data-sharing"
    ],
    "x-summary-ar": "إضافة نقطة استقبال ويب هوك؛ يظهر سر التوقيع مرة واحدة.",
    "parameters": [
     {
      "$ref": "#/components/parameters/IdempotencyKey"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookEndpointInput"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "The endpoint and its secret (shown only now).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookEndpointSecret"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-endpoints/{endpointId}": {
   "get": {
    "operationId": "getWebhookEndpoint",
    "summary": "One webhook endpoint.",
    "x-api-scope": "webhooks:read",
    "x-summary-ar": "نقطة استقبال ويب هوك.",
    "parameters": [
     {
      "name": "endpointId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d0-1a2b-7c3d-8e4f-5a6b7c8d9e0f"
     }
    ],
    "responses": {
     "200": {
      "description": "The endpoint.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookEndpoint"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "patch": {
    "operationId": "updateWebhookEndpoint",
    "summary": "Change an endpoint's URL, description, event types or enabled flag.",
    "description": "Fields given replace the stored ones; event_types replaces the list whole. enabled false stops deliveries (pending ones fail as endpoint_disabled); enabled true turns a disabled endpoint back on and clears its failure count.",
    "x-api-scope": "webhooks:write",
    "x-risk": [
     "data-sharing"
    ],
    "x-summary-ar": "تعديل نقطة استقبال ويب هوك.",
    "parameters": [
     {
      "name": "endpointId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d0-1a2b-7c3d-8e4f-5a6b7c8d9e0f"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookEndpointUpdate"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "The endpoint.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookEndpoint"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   },
   "delete": {
    "operationId": "deleteWebhookEndpoint",
    "summary": "Remove an endpoint with its deliveries.",
    "x-api-scope": "webhooks:write",
    "x-risk": [
     "data-sharing"
    ],
    "x-summary-ar": "حذف نقطة استقبال ويب هوك.",
    "parameters": [
     {
      "name": "endpointId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d0-1a2b-7c3d-8e4f-5a6b7c8d9e0f"
     }
    ],
    "responses": {
     "204": {
      "description": "Removed."
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-endpoints/{endpointId}/rotate-secret": {
   "post": {
    "operationId": "rotateWebhookSecret",
    "summary": "Replace an endpoint's signing secret; the new one is answered once and signs every delivery from now on.",
    "x-api-scope": "webhooks:write",
    "x-risk": [
     "data-sharing"
    ],
    "x-summary-ar": "تجديد سر توقيع نقطة استقبال الويب هوك.",
    "parameters": [
     {
      "name": "endpointId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d0-1a2b-7c3d-8e4f-5a6b7c8d9e0f"
     }
    ],
    "responses": {
     "200": {
      "description": "The endpoint and its new secret (shown only now).",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookEndpointSecret"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  },
  "/v1/webhook-endpoints/{endpointId}/test": {
   "post": {
    "operationId": "testWebhookEndpoint",
    "summary": "Send the endpoint a webhook.test event (signed, retried like any other); the delivery is answered.",
    "x-api-scope": "webhooks:write",
    "x-risk": [
     "data-sharing"
    ],
    "x-summary-ar": "إرسال حدث تجريبي إلى نقطة استقبال الويب هوك.",
    "parameters": [
     {
      "name": "endpointId",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "format": "uuid"
      },
      "example": "019ac0d0-1a2b-7c3d-8e4f-5a6b7c8d9e0f"
     }
    ],
    "responses": {
     "202": {
      "description": "The delivery, queued.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/WebhookDelivery"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadRequest"
     },
     "401": {
      "$ref": "#/components/responses/Unauthorized"
     },
     "403": {
      "$ref": "#/components/responses/Forbidden"
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "429": {
      "$ref": "#/components/responses/TooManyRequests"
     }
    },
    "security": [
     {
      "ApiKey": []
     }
    ]
   }
  }
 },
 "webhooks": {
  "alarm.opened": {
   "post": {
    "operationId": "deliverAlarmOpened",
    "summary": "A rule opened an alarm on a vehicle.",
    "x-summary-ar": "فتحت قاعدة تنبيهًا على مركبة.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookAlarmOpened"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "alarm.cleared": {
   "post": {
    "operationId": "deliverAlarmCleared",
    "summary": "An alarm was closed: by a person (with a resolution) or by the platform as its condition cleared.",
    "x-summary-ar": "أُغلق تنبيه.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookAlarmCleared"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "trip.ended": {
   "post": {
    "operationId": "deliverTripEnded",
    "summary": "A vehicle's trip ended (or a late record revised one already sent: revised, replaces).",
    "x-summary-ar": "انتهت رحلة مركبة.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookTripEnded"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "geofence.entered": {
   "post": {
    "operationId": "deliverGeofenceEntered",
    "summary": "A vehicle entered a geofence watched by a zone enter rule.",
    "x-summary-ar": "دخلت مركبة منطقة جغرافية.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookGeofence"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "geofence.exited": {
   "post": {
    "operationId": "deliverGeofenceExited",
    "summary": "A vehicle left a geofence watched by a zone exit rule.",
    "x-summary-ar": "خرجت مركبة من منطقة جغرافية.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookGeofence"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "job.dispatched": {
   "post": {
    "operationId": "deliverJobDispatched",
    "summary": "A job went to its driver.",
    "x-summary-ar": "أُرسلت مهمة إلى سائقها.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookJob"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "job.started": {
   "post": {
    "operationId": "deliverJobStarted",
    "summary": "A job's vehicle started it.",
    "x-summary-ar": "بدأت مهمة.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookJob"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "job.completed": {
   "post": {
    "operationId": "deliverJobCompleted",
    "summary": "Every stop of a job is done.",
    "x-summary-ar": "اكتملت مهمة.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookJob"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "job.cancelled": {
   "post": {
    "operationId": "deliverJobCancelled",
    "summary": "A job was cancelled.",
    "x-summary-ar": "أُلغيت مهمة.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookJob"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  },
  "webhook.test": {
   "post": {
    "operationId": "deliverTest",
    "summary": "A test event, sent only by testWebhookEndpoint.",
    "x-summary-ar": "حدث تجريبي.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookTest"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Any 2xx within 10 seconds is delivered; anything else is retried."
     }
    },
    "parameters": [
     {
      "name": "Ping-Signature",
      "in": "header",
      "required": true,
      "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the endpoint's secret>. Compute it over the body as received, compare in constant time, and reject a t more than 300 seconds from your clock.",
      "schema": {
       "type": "string",
       "pattern": "^t=[0-9]+,v1=[0-9a-f]{64}$"
      }
     },
     {
      "name": "Ping-Event-Id",
      "in": "header",
      "required": true,
      "description": "The payload's id.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     },
     {
      "name": "Ping-Event-Type",
      "in": "header",
      "required": true,
      "description": "The payload's type.",
      "schema": {
       "type": "string",
       "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
       "enum": [
        "alarm.opened",
        "alarm.cleared",
        "trip.ended",
        "geofence.entered",
        "geofence.exited",
        "job.dispatched",
        "job.started",
        "job.completed",
        "job.cancelled",
        "webhook.test"
       ],
       "example": "trip.ended"
      }
     },
     {
      "name": "Ping-Delivery-Id",
      "in": "header",
      "required": true,
      "description": "This delivery (getWebhookDelivery); a retry keeps it, a redelivery has its own.",
      "schema": {
       "type": "string",
       "format": "uuid"
      }
     }
    ]
   }
  }
 },
 "components": {
  "schemas": {
   "Accessory": {
    "type": "object",
    "description": "An approved accessory and the tracker models (or accessories) it works with.",
    "required": [
     "id",
     "name",
     "vendor",
     "kind",
     "addon",
     "summary",
     "works_with",
     "standalone",
     "links",
     "media",
     "product"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "DualCam"
     },
     "vendor": {
      "type": "string",
      "enum": [
       "teltonika"
      ],
      "example": "teltonika"
     },
     "kind": {
      "type": "string",
      "enum": [
       "dashcam",
       "camera_module",
       "sensor",
       "beacon",
       "can_adapter",
       "id_reader",
       "temp_probe",
       "cable",
       "satellite"
      ],
      "example": "dashcam"
     },
     "addon": {
      "type": [
       "string",
       "null"
      ],
      "description": "The subscription add-on it needs, if any.",
      "example": "camera"
     },
     "summary": {
      "type": "string",
      "example": "Road and in-cabin cameras in one housing, connected to the tracker"
     },
     "works_with": {
      "type": "array",
      "description": "The names of the tracker models (or accessories) it fits.",
      "items": {
       "type": "string"
      },
      "example": [
       "FMC125",
       "FMC225",
       "FMC650"
      ]
     },
     "standalone": {
      "type": "boolean",
      "description": "Works without a tracker (its own connectivity).",
      "example": false
     },
     "links": {
      "$ref": "#/components/schemas/CatalogLinks"
     },
     "media": {
      "$ref": "#/components/schemas/CatalogMedia"
     },
     "product": {
      "$ref": "#/components/schemas/ProductPage"
     }
    }
   },
   "AccessoryList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Accessory"
        }
       }
      }
     }
    ]
   },
   "Action": {
    "type": "string",
    "enum": [
     "alarm",
     "notify"
    ],
    "description": "alarm opens an alarm; notify sends a message to the account's users holding the rule's duty.",
    "example": "notify"
   },
   "Alarm": {
    "type": "object",
    "required": [
     "id",
     "rule_id",
     "vehicle_id",
     "kind",
     "severity",
     "status",
     "opened_at",
     "last_seen_at",
     "occurrences",
     "assignee",
     "acked_by",
     "acked_at",
     "closed_by",
     "closed_at",
     "resolution",
     "note",
     "position",
     "limit",
     "facts"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     },
     "rule_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The rule that opened the alarm; null once the rule is deleted.",
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid",
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     "kind": {
      "type": "string",
      "description": "The template id of the rule that opened the alarm, or custom.",
      "example": "overspeed"
     },
     "severity": {
      "$ref": "#/components/schemas/Severity"
     },
     "status": {
      "$ref": "#/components/schemas/AlarmStatus"
     },
     "opened_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "last_seen_at": {
      "type": "string",
      "format": "date-time",
      "description": "The latest occurrence: a repeat within the rule's minimum gap joins the open alarm.",
      "example": "2026-11-17T08:41:00Z"
     },
     "occurrences": {
      "type": "integer",
      "minimum": 1,
      "example": 2
     },
     "assignee": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The account user the alarm is given to.",
      "example": "019ac0c2-4d9c-7e1f-9a0b-2c3d4e5f6a7b"
     },
     "acked_by": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who acknowledged it: user:<id> or user:apikey/<key id>.",
      "example": "user:apikey/k7Qm2Lp9Xa4R"
     },
     "acked_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-11-17T08:34:10Z"
     },
     "closed_by": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who closed it (system: when the platform closed it as the condition cleared).",
      "example": null
     },
     "closed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": null
     },
     "resolution": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/Resolution"
       },
       {
        "type": "null"
       }
      ],
      "description": "How a person closed it; null until then, and when the platform closed it."
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "description": "The latest note given when acknowledging or closing.",
      "example": "Driver called; speed back to limit."
     },
     "position": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/Position"
       },
       {
        "type": "null"
       }
      ],
      "description": "Where the vehicle was when it opened."
     },
     "limit": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "The limit a condition compared with.",
      "example": 120
     },
     "facts": {
      "type": "array",
      "description": "The facts that held when it opened.",
      "items": {
       "$ref": "#/components/schemas/AlarmFact"
      }
     }
    }
   },
   "AlarmAck": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "note": {
      "type": "string",
      "maxLength": 1000,
      "example": "Driver called."
     }
    }
   },
   "AlarmActivity": {
    "type": "object",
    "description": "One change to an alarm, with what its kind carries: assigned the assignee; closed the resolution and note; acked an optional note; commented the note; repeated the occurrence it was.",
    "required": [
     "id",
     "at",
     "kind",
     "actor",
     "assignee",
     "resolution",
     "note",
     "occurrence"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "019ac0c7-3d4e-7f5a-9b6c-7d8e9f0a1b2c"
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:34:10Z"
     },
     "kind": {
      "$ref": "#/components/schemas/AlarmActivityKind"
     },
     "actor": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who did it (user:<id>); null when the platform did.",
      "example": "user:019ac0c2-4d9c-7e1f-9a0b-2c3d4e5f6a7b"
     },
     "assignee": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": "019ac0c2-4d9c-7e1f-9a0b-2c3d4e5f6a7b"
     },
     "resolution": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/Resolution"
       },
       {
        "type": "null"
       }
      ]
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "example": null
     },
     "occurrence": {
      "type": [
       "integer",
       "null"
      ],
      "example": null
     }
    }
   },
   "AlarmActivityKind": {
    "type": "string",
    "enum": [
     "opened",
     "repeated",
     "acked",
     "assigned",
     "commented",
     "closed",
     "reopened"
    ],
    "example": "assigned"
   },
   "AlarmAssign": {
    "type": "object",
    "required": [
     "assignee"
    ],
    "additionalProperties": false,
    "properties": {
     "assignee": {
      "type": "string",
      "format": "uuid",
      "description": "An account user id.",
      "example": "019ac0c2-4d9c-7e1f-9a0b-2c3d4e5f6a7b"
     }
    }
   },
   "AlarmClose": {
    "type": "object",
    "required": [
     "resolution",
     "note"
    ],
    "additionalProperties": false,
    "properties": {
     "resolution": {
      "$ref": "#/components/schemas/Resolution"
     },
     "note": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000,
      "example": "Driver called; speed back to limit."
     }
    }
   },
   "AlarmComment": {
    "type": "object",
    "required": [
     "text"
    ],
    "additionalProperties": false,
    "properties": {
     "text": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000,
      "example": "Called the driver; he is pulling over."
     }
    }
   },
   "AlarmDetail": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Alarm"
     },
     {
      "type": "object",
      "required": [
       "activity"
      ],
      "properties": {
       "activity": {
        "type": "array",
        "description": "Oldest first.",
        "items": {
         "$ref": "#/components/schemas/AlarmActivity"
        }
       }
      }
     }
    ]
   },
   "AlarmFact": {
    "type": "object",
    "description": "A fact the rule read and the value it had when the alarm opened: one of number, text or boolean.",
    "required": [
     "fact"
    ],
    "properties": {
     "fact": {
      "$ref": "#/components/schemas/Fact"
     },
     "number": {
      "type": "number",
      "format": "double",
      "example": 134
     },
     "text": {
      "type": "string",
      "example": "open"
     },
     "boolean": {
      "type": "boolean",
      "example": true
     }
    }
   },
   "AlarmList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Alarm"
        }
       }
      }
     }
    ]
   },
   "AlarmStatus": {
    "type": "string",
    "enum": [
     "open",
     "acked",
     "closed"
    ],
    "description": "open, then acked (optional), then closed.",
    "example": "acked"
   },
   "CargoDisposition": {
    "type": "object",
    "required": [
     "outcome",
     "reason",
     "receiver_name",
     "recorded_by",
     "recorded_at"
    ],
    "properties": {
     "outcome": {
      "$ref": "#/components/schemas/DispositionOutcome"
     },
     "reason": {
      "type": [
       "string",
       "null"
      ]
     },
     "receiver_name": {
      "type": "string",
      "example": "Store manager"
     },
     "recorded_by": {
      "type": "string",
      "example": "user:usr_Qm4rT8wZ1"
     },
     "recorded_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T10:12:00Z"
     }
    }
   },
   "CatalogLinks": {
    "type": "object",
    "description": "The manufacturer's pages for the product (the wiki's IO and parameter pages for a model), the answer each gave when checked, and when they were checked.",
    "required": [
     "product",
     "checked"
    ],
    "additionalProperties": false,
    "properties": {
     "product": {
      "type": "string",
      "format": "uri",
      "example": "https://www.teltonika-gps.com/products/trackers/advanced/fmc130"
     },
     "product_status": {
      "type": [
       "integer",
       "null"
      ],
      "description": "The product page's HTTP status when checked.",
      "example": 200
     },
     "wiki_io_parameters": {
      "type": "string",
      "format": "uri",
      "example": "https://wiki.teltonika-gps.com/view/FMC130_Teltonika_Data_Sending_Parameters_ID"
     },
     "wiki_parameter_list": {
      "type": "string",
      "format": "uri",
      "example": "https://wiki.teltonika-gps.com/view/FMC130_Parameter_list"
     },
     "wiki_status": {
      "type": [
       "integer",
       "null"
      ],
      "description": "The wiki pages' HTTP status when checked (403: behind a bot check).",
      "example": 403
     },
     "wiki_saved_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "description": "When the wiki's IO page was saved into PING's IO dictionary.",
      "example": "2026-11-15"
     },
     "checked": {
      "type": "string",
      "format": "date",
      "example": "2026-11-15"
     }
    }
   },
   "CatalogMedia": {
    "type": "object",
    "description": "Product photos and a 3D model (glTF binary), hosted by the manufacturer.",
    "required": [
     "photos"
    ],
    "additionalProperties": false,
    "properties": {
     "photos": {
      "type": "array",
      "items": {
       "type": "string",
       "format": "uri"
      },
      "example": [
       "https://static.wixstatic.com/media/83e479_22b33b1a25304cccafd04584c7a3ff41~mv2.png"
      ]
     },
     "model_3d": {
      "type": "string",
      "format": "uri",
      "example": "https://static.wixstatic.com/3d/83e479_726cd4f1af15454abcea86c54ccd46ee.glb"
     }
    }
   },
   "CoachingFocus": {
    "type": "string",
    "enum": [
     "harsh_braking",
     "harsh_acceleration",
     "harsh_cornering",
     "overspeed"
    ],
    "example": "harsh_braking"
   },
   "CoachingSession": {
    "type": "object",
    "required": [
     "id",
     "driver_id",
     "at",
     "coach",
     "focus",
     "note",
     "score_at_session",
     "follow_up_on"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "driver_id": {
      "$ref": "#/components/schemas/Id"
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "coach": {
      "type": "string",
      "description": "Who held it (the caller)",
      "example": "user:usr_4Kd9"
     },
     "focus": {
      "$ref": "#/components/schemas/CoachingFocus"
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "example": "Reviewed the three braking events on the Dammam run"
     },
     "score_at_session": {
      "type": [
       "integer",
       "null"
      ],
      "example": 58
     },
     "follow_up_on": {
      "type": "string",
      "format": "date",
      "example": "2026-12-01"
     }
    }
   },
   "CoachingSessionInput": {
    "type": "object",
    "required": [
     "driver_id",
     "focus",
     "follow_up_on"
    ],
    "additionalProperties": false,
    "properties": {
     "driver_id": {
      "$ref": "#/components/schemas/Id"
     },
     "focus": {
      "$ref": "#/components/schemas/CoachingFocus"
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 500,
      "example": "Reviewed the three braking events on the Dammam run"
     },
     "score_at_session": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 0,
      "maximum": 100,
      "example": 58
     },
     "follow_up_on": {
      "type": "string",
      "format": "date",
      "example": "2026-12-01"
     }
    }
   },
   "CoachingSessionList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/CoachingSession"
        }
       }
      }
     }
    ]
   },
   "Codec": {
    "type": "string",
    "enum": [
     "8",
     "8E",
     "12",
     "13",
     "14",
     "16"
    ],
    "example": "8E"
   },
   "Command": {
    "type": "object",
    "description": "A command to a tracker. queued: waiting for the device; sent: delivered; acked: the device replied; succeeded or failed: the outcome; expired: not delivered in time.",
    "required": [
     "id",
     "imei",
     "vehicle_id",
     "kind",
     "status",
     "requested_by",
     "created_at",
     "expires_at",
     "sent_at",
     "result"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     },
     "imei": {
      "$ref": "#/components/schemas/FieldImei"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The vehicle the device was installed in when the command was made.",
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     "kind": {
      "$ref": "#/components/schemas/CommandKind"
     },
     "status": {
      "$ref": "#/components/schemas/CommandStatus"
     },
     "requested_by": {
      "type": "string",
      "description": "Who made the command: user:<id>, or user:apikey/<key id> for an API key.",
      "example": "user:apikey/k7Pq2Wn8Lx4R"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T09:42:03Z"
     },
     "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "A command not sent by then expires.",
      "example": "2026-11-17T09:52:03Z"
     },
     "sent_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": null
     },
     "result": {
      "type": [
       "string",
       "null"
      ],
      "description": "The device's reply.",
      "example": null
     }
    }
   },
   "CommandKind": {
    "type": "string",
    "enum": [
     "text",
     "immobilizer_cut",
     "immobilizer_restore",
     "profile"
    ],
    "description": "text: a staff command; immobilizer_cut and immobilizer_restore: the engine output; profile: one write of an approved profile.",
    "example": "immobilizer_cut"
   },
   "CommandStatus": {
    "type": "string",
    "enum": [
     "queued",
     "sent",
     "acked",
     "succeeded",
     "failed",
     "expired",
     "cancelled"
    ],
    "description": "cancelled: a profile push's text not sent because an earlier one was refused or failed.",
    "example": "queued"
   },
   "Condition": {
    "type": "object",
    "description": "One condition of a rule; all conditions of a rule hold together. It compares the fact with exactly one of number, text, boolean or the rule's limit (limit: true); changed compares with nothing, drop with a positive number fallen within window_s.",
    "required": [
     "fact",
     "op"
    ],
    "additionalProperties": false,
    "properties": {
     "fact": {
      "$ref": "#/components/schemas/Fact"
     },
     "op": {
      "type": "string",
      "enum": [
       "=",
       "!=",
       ">",
       ">=",
       "<",
       "<=",
       "changed",
       "drop"
      ],
      "description": "changed: the value differs from the previous record. drop: the value fell by at least number within window_s.",
      "example": ">"
     },
     "number": {
      "type": "number",
      "format": "double",
      "description": "Compare with this number.",
      "example": 100
     },
     "text": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Compare with this text (= and != only).",
      "example": "open"
     },
     "boolean": {
      "type": "boolean",
      "description": "Compare with this boolean (= and != only).",
      "example": true
     },
     "limit": {
      "type": "boolean",
      "enum": [
       true
      ],
      "description": "Compare with the rule's limit.",
      "example": true
     },
     "window_s": {
      "type": "integer",
      "minimum": 1,
      "maximum": 86400,
      "description": "Seconds over which drop is measured; only for drop.",
      "example": 900
     }
    }
   },
   "Contact": {
    "type": "object",
    "required": [
     "id",
     "phone",
     "user_id",
     "language",
     "whatsapp_opt_in",
     "created_at"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "phone": {
      "$ref": "#/components/schemas/FieldPhone"
     },
     "user_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "language": {
      "type": "string",
      "enum": [
       "ar",
       "en"
      ],
      "example": "ar"
     },
     "whatsapp_opt_in": {
      "type": "boolean",
      "example": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-09-02T09:25:00Z"
     }
    }
   },
   "ContactInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "phone"
    ],
    "properties": {
     "phone": {
      "type": "string",
      "description": "E.164, or a Saudi number as typed.",
      "example": "0501234567"
     },
     "user_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "language": {
      "type": "string",
      "enum": [
       "ar",
       "en"
      ],
      "default": "ar"
     }
    }
   },
   "ContactList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Contact"
        }
       }
      }
     }
    ]
   },
   "CrRecord": {
    "type": "object",
    "description": "A commercial registration as the Business Center's registry answered (GetCrDetails), the fields PING keeps.",
    "required": [
     "cr_number",
     "national_number",
     "status_id",
     "status_ar",
     "status_en",
     "active",
     "entity_type_ar",
     "entity_type_en",
     "company_form_ar",
     "company_form_en",
     "name_ar",
     "name_en",
     "capital_sar",
     "is_main",
     "main_cr_number",
     "main_national_number",
     "in_liquidation",
     "has_ecommerce",
     "issued_on",
     "issued_on_hijri",
     "confirm_on",
     "confirm_on_hijri",
     "modified_on",
     "modified_on_hijri",
     "deleted_on",
     "owner",
     "national_address",
     "unit_number",
     "contact",
     "activities",
     "managers",
     "read_at"
    ],
    "properties": {
     "cr_number": {
      "$ref": "#/components/schemas/FieldCrNumber"
     },
     "national_number": {
      "$ref": "#/components/schemas/FieldUnifiedNumber"
     },
     "status_id": {
      "type": "integer"
     },
     "status_ar": {
      "type": "string"
     },
     "status_en": {
      "type": "string"
     },
     "active": {
      "type": "boolean"
     },
     "entity_type_ar": {
      "type": "string"
     },
     "entity_type_en": {
      "type": "string"
     },
     "company_form_ar": {
      "type": [
       "string",
       "null"
      ]
     },
     "company_form_en": {
      "type": [
       "string",
       "null"
      ]
     },
     "name_ar": {
      "type": "string"
     },
     "name_en": {
      "type": [
       "string",
       "null"
      ]
     },
     "capital_sar": {
      "type": [
       "number",
       "null"
      ],
      "format": "double"
     },
     "is_main": {
      "type": "boolean"
     },
     "main_cr_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldCrNumber"
       },
       {
        "type": "null"
       }
      ]
     },
     "main_national_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldUnifiedNumber"
       },
       {
        "type": "null"
       }
      ]
     },
     "in_liquidation": {
      "type": "boolean"
     },
     "has_ecommerce": {
      "type": "boolean"
     },
     "issued_on": {
      "type": "string",
      "format": "date"
     },
     "issued_on_hijri": {
      "type": [
       "string",
       "null"
      ],
      "description": "DD-MM-YYYY, Umm al-Qura"
     },
     "confirm_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "description": "The yearly confirmation date"
     },
     "confirm_on_hijri": {
      "type": [
       "string",
       "null"
      ]
     },
     "modified_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "modified_on_hijri": {
      "type": [
       "string",
       "null"
      ]
     },
     "deleted_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "owner": {
      "oneOf": [
       {
        "type": "object",
        "required": [
         "name_ar",
         "name_en",
         "id_type_en",
         "id_number"
        ],
        "properties": {
         "name_ar": {
          "type": [
           "string",
           "null"
          ]
         },
         "name_en": {
          "type": [
           "string",
           "null"
          ]
         },
         "id_type_en": {
          "type": [
           "string",
           "null"
          ]
         },
         "id_number": {
          "type": [
           "string",
           "null"
          ]
         }
        }
       },
       {
        "type": "null"
       }
      ]
     },
     "national_address": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/NationalAddress"
       },
       {
        "type": "null"
       }
      ],
      "description": "As the CR carries it (no short address); null when the registry gave an incomplete one"
     },
     "unit_number": {
      "type": [
       "string",
       "null"
      ]
     },
     "contact": {
      "type": "object",
      "required": [
       "phone",
       "mobile",
       "email",
       "website"
      ],
      "properties": {
       "phone": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/FieldPhone"
         },
         {
          "type": "null"
         }
        ]
       },
       "mobile": {
        "oneOf": [
         {
          "$ref": "#/components/schemas/FieldPhone"
         },
         {
          "type": "null"
         }
        ]
       },
       "email": {
        "type": [
         "string",
         "null"
        ]
       },
       "website": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     },
     "activities": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "code",
        "description_ar",
        "description_en"
       ],
       "properties": {
        "code": {
         "type": "string",
         "description": "ISIC activity code"
        },
        "description_ar": {
         "type": "string"
        },
        "description_en": {
         "type": [
          "string",
          "null"
         ]
        }
       }
      }
     },
     "managers": {
      "type": "array",
      "items": {
       "type": "object",
       "required": [
        "name_ar",
        "name_en",
        "manager_type_en",
        "nationality_en",
        "id_type_en",
        "id_number",
        "licensed"
       ],
       "properties": {
        "name_ar": {
         "type": [
          "string",
          "null"
         ]
        },
        "name_en": {
         "type": [
          "string",
          "null"
         ]
        },
        "manager_type_en": {
         "type": [
          "string",
          "null"
         ]
        },
        "nationality_en": {
         "type": [
          "string",
          "null"
         ]
        },
        "id_type_en": {
         "type": [
          "string",
          "null"
         ]
        },
        "id_number": {
         "type": [
          "string",
          "null"
         ],
         "description": "Null where the registry masks it"
        },
        "licensed": {
         "type": "boolean"
        }
       }
      }
     },
     "read_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "Customer": {
    "type": "object",
    "required": [
     "id",
     "name_ar",
     "name_en",
     "cr_number",
     "vat_number",
     "vat_status",
     "tin",
     "registration",
     "status",
     "expires_at",
     "tga_licence_number",
     "tga_licence_expires_on",
     "national_address",
     "operating_week",
     "operating_hours",
     "created_at"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "name_ar": {
      "type": "string",
      "example": "شركة النقل المتحدة"
     },
     "name_en": {
      "type": "string",
      "example": "United Transport Co."
     },
     "cr_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldCrNumber"
       },
       {
        "type": "null"
       }
      ],
      "description": "Commercial Registration number."
     },
     "unified_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldUnifiedNumber"
       },
       {
        "type": "null"
       }
      ],
      "description": "The Unified National Number (700) replacing the CR number under the 2025 Commercial Register Law."
     },
     "vat_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldVatNumber"
       },
       {
        "type": "null"
       }
      ]
     },
     "vat_status": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "registered",
       "not_subject",
       "not_registered",
       null
      ],
      "description": "From the ZATCA documents sent with the CR: a VAT certificate (registered), a registration notice (not subject), or only the general registration certificate (not registered for VAT); null when none was sent."
     },
     "tin": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldTin"
       },
       {
        "type": "null"
       }
      ],
      "description": "ZATCA's distinctive number (TIN), from its document."
     },
     "registration": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/CrRecord"
       },
       {
        "type": "null"
       }
      ],
      "description": "The commercial registration the identity was filled from, as the Ministry of Commerce's registry answered for the certificate's QR."
     },
     "status": {
      "type": "string",
      "example": "active"
     },
     "expires_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "description": "When the subscription ends unless renewed.",
      "example": "2027-08-31"
     },
     "tga_licence_number": {
      "type": [
       "string",
       "null"
      ],
      "description": "The Transport General Authority licence for transport activity.",
      "example": "TGA-1043398"
     },
     "tga_licence_expires_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2027-03-14"
     },
     "national_address": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/NationalAddress"
       },
       {
        "type": "null"
       }
      ]
     },
     "operating_week": {
      "type": "array",
      "minItems": 7,
      "maxItems": 7,
      "items": {
       "type": "string",
       "enum": [
        "full",
        "short",
        "closed"
       ]
      },
      "description": "Sunday first: what each day of the week is.",
      "example": [
       "full",
       "full",
       "full",
       "full",
       "full",
       "closed",
       "closed"
      ]
     },
     "operating_hours": {
      "$ref": "#/components/schemas/OperatingHours"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-09-01T08:00:00Z"
     }
    }
   },
   "DailyStat": {
    "type": "object",
    "required": [
     "date",
     "distance_m",
     "driving_s",
     "idle_s",
     "engine_s",
     "max_speed_kmh",
     "trips",
     "harsh_events",
     "overspeed",
     "fuel_used_l"
    ],
    "properties": {
     "date": {
      "type": "string",
      "format": "date",
      "description": "The Riyadh calendar day.",
      "example": "2026-11-16"
     },
     "distance_m": {
      "type": "number",
      "format": "double",
      "description": "Distance over valid positions, metres.",
      "example": 84210
     },
     "driving_s": {
      "type": "integer",
      "description": "Driving time of the trips that started that day, seconds.",
      "example": 9120
     },
     "idle_s": {
      "type": "integer",
      "description": "Idle time of the trips that started that day, seconds.",
      "example": 1410
     },
     "engine_s": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Engine time from the device's engine hours counter, seconds; null when the device does not report it.",
      "example": 11200
     },
     "max_speed_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "example": 118
     },
     "trips": {
      "type": "integer",
      "example": 7
     },
     "harsh_events": {
      "type": "integer",
      "description": "Harsh acceleration, braking and cornering events that day.",
      "example": 3
     },
     "overspeed": {
      "type": "integer",
      "description": "Overspeeding events that day.",
      "example": 1
     },
     "fuel_used_l": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "Fuel used that day, from the engine's fuel counter; null when the device does not report it.",
      "example": 31.8
     }
    }
   },
   "DailyStats": {
    "type": "object",
    "required": [
     "vehicle_id",
     "from",
     "to",
     "data"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "from": {
      "type": "string",
      "format": "date",
      "example": "2026-11-10"
     },
     "to": {
      "type": "string",
      "format": "date",
      "example": "2026-11-16"
     },
     "data": {
      "type": "array",
      "description": "Days with data, oldest first.",
      "items": {
       "$ref": "#/components/schemas/DailyStat"
      }
     }
    }
   },
   "Datasheet": {
    "type": "object",
    "description": "Facts from the manufacturer's datasheet, as published (units in the field name or the value). Fields a datasheet does not give are left out.",
    "required": [
     "file",
     "version",
     "input_voltage_v",
     "digital_inputs",
     "digital_outputs",
     "ingress",
     "ignition_detection"
    ],
    "additionalProperties": false,
    "properties": {
     "file": {
      "type": "string",
      "example": "DS-FMC130.pdf"
     },
     "version": {
      "type": "string",
      "example": "1.1 (2026)"
     },
     "dimensions_mm": {
      "type": "string",
      "example": "65 x 56.6 x 20.6"
     },
     "weight_g": {
      "type": "number",
      "format": "double",
      "example": 61
     },
     "input_voltage_v": {
      "type": "string",
      "example": "10-30"
     },
     "backup_battery": {
      "type": "string",
      "example": "170 mAh Li-Ion (0.63 Wh)"
     },
     "battery": {
      "type": "string",
      "description": "Main battery, for self-powered models.",
      "example": "Li-SOCl2 swappable, 7.2 V 2200 mAh"
     },
     "digital_inputs": {
      "type": "integer",
      "example": 3
     },
     "digital_outputs": {
      "type": "integer",
      "description": "0 means the model has no immobilizer output.",
      "example": 3
     },
     "analog_inputs": {
      "type": "integer",
      "example": 2
     },
     "one_wire": {
      "type": "integer",
      "example": 1
     },
     "can": {
      "type": "string",
      "example": "1 CAN adapter input (LV-CAN200, ALL-CAN300, CAN-CONTROL)"
     },
     "obd": {
      "type": "string",
      "example": "via BLE OBDII dongle"
     },
     "serial": {
      "type": "string",
      "example": "none"
     },
     "ingress": {
      "type": "string",
      "description": "IP rating.",
      "example": "IP41"
     },
     "antennas": {
      "type": "string",
      "example": "internal"
     },
     "sim": {
      "type": "string",
      "example": "Micro-SIM or eSIM"
     },
     "ignition_detection": {
      "type": "string",
      "example": "DIN1, accelerometer, external voltage, engine RPM (CAN adapters, OBDII dongle)"
     },
     "fuel_monitoring": {
      "type": "string",
      "example": "LLS (analog), LV-CAN200, ALL-CAN300, CAN-CONTROL, OBDII dongle"
     },
     "lte_bands": {
      "type": "string",
      "example": "FMC130-ME1: LTE B1/B3/B5/B7/B8/B20, TDD B38/B40/B41"
     },
     "variants": {
      "type": "string",
      "description": "Hardware variants that differ in inputs and outputs.",
      "example": "FMC150-QJIB0 (EU/MEA): 3 DIN, 2 DOUT, 2 AIN"
     }
    }
   },
   "Department": {
    "type": "object",
    "required": [
     "id",
     "name",
     "parent_id",
     "cost_centre",
     "created_at"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "name": {
      "type": "string",
      "example": "Riyadh distribution"
     },
     "parent_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The parent department; null at the top of the tree.",
      "example": null
     },
     "cost_centre": {
      "type": [
       "string",
       "null"
      ],
      "description": "The code the department's costs are booked to.",
      "example": "CC-410"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-09-02T09:15:00Z"
     }
    }
   },
   "DepartmentInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "name"
    ],
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Riyadh distribution"
     },
     "parent_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": null
     }
    }
   },
   "DepartmentList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Department"
        }
       }
      }
     }
    ]
   },
   "DeviceHealth": {
    "type": "object",
    "required": [
     "imei",
     "model",
     "status",
     "vehicle_id",
     "installed_at",
     "firmware",
     "config_profile",
     "sim",
     "state"
    ],
    "properties": {
     "imei": {
      "$ref": "#/components/schemas/FieldImei"
     },
     "model": {
      "type": "string",
      "example": "FMC130"
     },
     "status": {
      "$ref": "#/components/schemas/DeviceStatus"
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid",
      "description": "The vehicle the device is installed in.",
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     "installed_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-09-14T07:30:00Z"
     },
     "firmware": {
      "type": [
       "string",
       "null"
      ],
      "example": "03.29.05.Rev.02"
     },
     "config_profile": {
      "type": [
       "string",
       "null"
      ],
      "description": "The model whose approved configuration profile was pushed to the device.",
      "example": "FMC130"
     },
     "sim": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/HealthSim"
       },
       {
        "type": "null"
       }
      ],
      "description": "The SIM paired with the device now."
     },
     "state": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/DeviceState"
       },
       {
        "type": "null"
       }
      ],
      "description": "The latest state the device reported; null when none is available."
     }
    }
   },
   "DeviceState": {
    "type": "object",
    "description": "The latest state the device reported, as telemetry knows it.",
    "required": [
     "reported_at",
     "connected",
     "speed_kmh",
     "ignition",
     "gnss_fix",
     "satellites",
     "external_voltage_mv",
     "battery_voltage_mv"
    ],
    "properties": {
     "reported_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T09:41:12Z"
     },
     "connected": {
      "type": "boolean",
      "description": "The device holds a connection to PING now.",
      "example": true
     },
     "speed_kmh": {
      "type": "number",
      "format": "double",
      "example": 0
     },
     "ignition": {
      "type": [
       "boolean",
       "null"
      ],
      "example": false
     },
     "gnss_fix": {
      "type": [
       "boolean",
       "null"
      ],
      "example": true
     },
     "satellites": {
      "type": [
       "integer",
       "null"
      ],
      "example": 14
     },
     "external_voltage_mv": {
      "type": [
       "integer",
       "null"
      ],
      "example": 12840
     },
     "battery_voltage_mv": {
      "type": [
       "integer",
       "null"
      ],
      "example": 4102
     }
    }
   },
   "DeviceStatus": {
    "type": "string",
    "enum": [
     "stock",
     "installed",
     "faulty",
     "returned",
     "retired",
     "released"
    ],
    "description": "stock: held by PING; installed: in a vehicle; faulty: diagnosed or awaiting an RMA; returned: sent back to the supplier; retired: out of use; released: the customer's, staying with an account that left PING (ingest refuses its data).",
    "example": "installed"
   },
   "DispatchedJob": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Job"
     },
     {
      "type": "object",
      "required": [
       "driver_link"
      ],
      "properties": {
       "driver_link": {
        "type": [
         "string",
         "null"
        ],
        "description": "The driver's job link, also sent to the driver on WhatsApp; null when the job was not dispatched",
        "example": "https://example.com/drive#019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d.q8XcT0vW"
       }
      }
     }
    ]
   },
   "DispositionOutcome": {
    "type": "string",
    "enum": [
     "accepted",
     "rejected",
     "quarantined"
    ],
    "example": "quarantined"
   },
   "Driver": {
    "type": "object",
    "required": [
     "id",
     "name",
     "name_ar",
     "department_id",
     "phone_e164",
     "national_id",
     "iqama_number",
     "licence_classes",
     "licence_expiry",
     "ibutton_id",
     "created_at",
     "updated_at",
     "left_on",
     "leave_reason"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "description": "The name in Latin letters",
      "example": "Faisal Al-Harbi"
     },
     "name_ar": {
      "type": [
       "string",
       "null"
      ],
      "description": "The name in Arabic",
      "example": "فيصل الحربي"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The account department the driver belongs to"
     },
     "phone_e164": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPhoneKsa"
       },
       {
        "type": "null"
       }
      ],
      "description": "Job links are sent here on WhatsApp"
     },
     "national_id": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldNationalId"
       },
       {
        "type": "null"
       }
      ],
      "description": "A Saudi driver's national ID, the number their licence is issued on"
     },
     "iqama_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldIqamaNumber"
       },
       {
        "type": "null"
       }
      ],
      "description": "A resident driver's Iqama, the number their licence is issued on"
     },
     "licence_classes": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/FieldLicenceClass"
      },
      "description": "The classes the driving licence holds"
     },
     "licence_expiry": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2028-05-14"
     },
     "ibutton_id": {
      "type": [
       "string",
       "null"
      ],
      "description": "The iButton key that identifies the driver in the vehicle (hex)",
      "example": "01A2B3C4D5E6"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "left_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "description": "The day the driver left the account; null while employed"
     },
     "leave_reason": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/LeaveReason"
       },
       {
        "type": "null"
       }
      ]
     }
    }
   },
   "DriverAssignment": {
    "type": "object",
    "required": [
     "driver_id"
    ],
    "additionalProperties": false,
    "properties": {
     "driver_id": {
      "$ref": "#/components/schemas/Id"
     }
    }
   },
   "DriverInput": {
    "type": "object",
    "required": [
     "name"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Faisal Al-Harbi"
     },
     "name_ar": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 120,
      "example": "فيصل الحربي"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "phone_e164": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPhoneKsa"
       },
       {
        "type": "null"
       }
      ]
     },
     "national_id": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldNationalId"
       },
       {
        "type": "null"
       }
      ],
      "description": "Not with iqama_number"
     },
     "iqama_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldIqamaNumber"
       },
       {
        "type": "null"
       }
      ],
      "description": "Not with national_id"
     },
     "licence_classes": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/FieldLicenceClass"
      }
     },
     "licence_expiry": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2028-05-14"
     },
     "ibutton_id": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^[0-9A-Fa-f]{1,32}$",
      "example": "01A2B3C4D5E6"
     }
    }
   },
   "DriverList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Driver"
        }
       }
      }
     }
    ]
   },
   "DriverSession": {
    "type": "object",
    "required": [
     "id",
     "vehicle_id",
     "driver_id",
     "source",
     "started_at",
     "ended_at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "driver_id": {
      "$ref": "#/components/schemas/Id"
     },
     "source": {
      "type": "string",
      "enum": [
       "manual",
       "ibutton"
      ],
      "description": "manual: assigned through the API or console; ibutton: identified in the vehicle",
      "example": "manual"
     },
     "started_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "ended_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "Null while the session is open"
     }
    }
   },
   "DriverUpdate": {
    "type": "object",
    "description": "The fields to change; null clears a field. name cannot be null.",
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Faisal Al-Harbi"
     },
     "name_ar": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 120,
      "example": "فيصل الحربي"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "phone_e164": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPhoneKsa"
       },
       {
        "type": "null"
       }
      ]
     },
     "national_id": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldNationalId"
       },
       {
        "type": "null"
       }
      ]
     },
     "iqama_number": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldIqamaNumber"
       },
       {
        "type": "null"
       }
      ]
     },
     "licence_classes": {
      "type": "array",
      "maxItems": 8,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/FieldLicenceClass"
      }
     },
     "licence_expiry": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2028-05-14"
     },
     "ibutton_id": {
      "type": [
       "string",
       "null"
      ],
      "pattern": "^[0-9A-Fa-f]{1,32}$",
      "example": "01A2B3C4D5E6"
     }
    }
   },
   "DrivingScore": {
    "type": "object",
    "required": [
     "vehicle_id",
     "driver_id",
     "week",
     "distance_m",
     "driving_s",
     "idle_s",
     "harsh_acceleration",
     "harsh_braking",
     "harsh_cornering",
     "overspeed",
     "score"
    ],
    "properties": {
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The vehicle; null when scoring by driver."
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The driver when scoring by driver; null there for trips no driver was known for, and always null by vehicle.",
      "example": null
     },
     "week": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "description": "The Sunday the Riyadh week starts with, per week; null over the period.",
      "example": null
     },
     "distance_m": {
      "type": "number",
      "format": "double",
      "example": 412300
     },
     "driving_s": {
      "type": "integer",
      "example": 41200
     },
     "idle_s": {
      "type": "integer",
      "example": 3600
     },
     "harsh_acceleration": {
      "type": "integer",
      "description": "Harsh acceleration events the device reported.",
      "example": 1
     },
     "harsh_braking": {
      "type": "integer",
      "example": 2
     },
     "harsh_cornering": {
      "type": "integer",
      "example": 0
     },
     "overspeed": {
      "type": "integer",
      "description": "Overspeeding events (the device's own speed limit).",
      "example": 1
     },
     "score": {
      "type": [
       "integer",
       "null"
      ],
      "description": "0 to 100, higher is safer: harsh and overspeeding events per 100 km and the share of idling. Null under the minimum distance.",
      "example": 86
     }
    }
   },
   "DrivingScores": {
    "type": "object",
    "required": [
     "from",
     "to",
     "by",
     "per",
     "data"
    ],
    "properties": {
     "from": {
      "type": "string",
      "format": "date",
      "example": "2026-11-10"
     },
     "to": {
      "type": "string",
      "format": "date",
      "example": "2026-11-16"
     },
     "by": {
      "type": "string",
      "enum": [
       "vehicle",
       "driver"
      ],
      "example": "vehicle"
     },
     "per": {
      "type": "string",
      "enum": [
       "period",
       "week"
      ],
      "example": "period"
     },
     "data": {
      "type": "array",
      "description": "One entry per vehicle (or driver) with trips in the period (per week, per week with trips), by week then id.",
      "items": {
       "$ref": "#/components/schemas/DrivingScore"
      }
     }
    }
   },
   "Duty": {
    "type": "string",
    "enum": [
     "dispatch",
     "workshop",
     "fuel",
     "cold_chain",
     "compliance",
     "safety"
    ]
   },
   "Fact": {
    "type": "string",
    "pattern": "^(position|state|geofence|vehicle|alarm|rider|signal|cargo)\\.[a-z][a-z0-9_]*$",
    "maxLength": 80,
    "description": "A namespaced fact: position.* (the latest record; position.priority the highest record priority, 2 = panic), state.* (device state), signal.<key> (one measurement whichever model reports it: a device IO element is read as the signal it maps to in infra/devices/io/signals.toml), geofence.*, vehicle.*, alarm.*, rider.* (rider.onboard, rider.unknown_card) or cargo.* (cargo.warmest_c, cargo.coldest_c: the compartment's probes).",
    "example": "position.speed_kmh"
   },
   "FieldAdditionalNumber": {
    "type": "string",
    "description": "National address additional (secondary) number",
    "x-field": "additional_number",
    "pattern": "^[0-9]{4}$",
    "maxLength": 4,
    "example": "8118"
   },
   "FieldAddressLine": {
    "type": "string",
    "description": "Street name",
    "x-field": "address_line",
    "pattern": "^\\S(.*\\S)?$",
    "maxLength": 1000,
    "example": "Rayhanah Bint Zaid"
   },
   "FieldAddressPlace": {
    "type": "string",
    "description": "City or district name",
    "x-field": "address_place",
    "pattern": "^\\S(.*\\S)?$",
    "maxLength": 127,
    "example": "Riyadh"
   },
   "FieldBuildingNumber": {
    "type": "string",
    "description": "National address building number",
    "x-field": "building_number",
    "pattern": "^[0-9]{4}$",
    "maxLength": 4,
    "example": "2929"
   },
   "FieldCrNumber": {
    "type": "string",
    "description": "Commercial Registration number",
    "x-field": "cr_number",
    "pattern": "^[0-9]{10}$",
    "maxLength": 10,
    "example": "1010010000"
   },
   "FieldEmail": {
    "type": "string",
    "description": "Email address",
    "x-field": "email",
    "pattern": "^[^@\\s]{1,64}@[^@\\s]+\\.[^@\\s]{2,}$",
    "maxLength": 254,
    "example": "fahad@example.com"
   },
   "FieldIccid": {
    "type": "string",
    "description": "SIM card number (Integrated Circuit Card Identifier)",
    "x-field": "iccid",
    "pattern": "^89[0-9]{17}$",
    "maxLength": 19,
    "example": "8996601234567890123"
   },
   "FieldImei": {
    "type": "string",
    "description": "International Mobile Equipment Identity",
    "x-field": "imei",
    "pattern": "^[0-9]{15}$",
    "maxLength": 15,
    "example": "490154203237518"
   },
   "FieldIqamaNumber": {
    "type": "string",
    "description": "Resident identity (Iqama) number",
    "x-field": "iqama_number",
    "pattern": "^2[0-9]{9}$",
    "maxLength": 10,
    "example": "2412345678"
   },
   "FieldLicenceClass": {
    "type": "string",
    "description": "Saudi driving licence type",
    "x-field": "licence_class",
    "enum": [
     "private",
     "public_taxi",
     "public_light_transport",
     "public_heavy_transport",
     "public_small_bus",
     "public_large_bus",
     "public_works",
     "motorcycle"
    ],
    "example": "private"
   },
   "FieldNationalId": {
    "type": "string",
    "description": "Saudi national ID number",
    "x-field": "national_id",
    "pattern": "^1[0-9]{9}$",
    "maxLength": 10,
    "example": "1012345678"
   },
   "FieldPhone": {
    "type": "string",
    "description": "Telephone number in E.164 (any country)",
    "x-field": "phone",
    "pattern": "^\\+[1-9][0-9]{7,14}$",
    "maxLength": 16,
    "example": "+966551234567"
   },
   "FieldPhoneKsa": {
    "type": "string",
    "description": "Saudi telephone number in E.164 (mobile, landline, VoIP, unified)",
    "x-field": "phone_ksa",
    "pattern": "^\\+966(5[0-9]{8}|1[123467][2-8][0-9]{6}|3[12][0-9]{7}|9200[0-9]{5})$",
    "maxLength": 13,
    "example": "+966551234567"
   },
   "FieldPlate": {
    "type": "string",
    "description": "Saudi plate as one string, as the dashcam reads it: 1-4 digits then 2-3 letters (Latin form)",
    "x-field": "plate",
    "pattern": "^[0-9]{1,4}[ABDEGHJKLNRSTUVXZ]{2,3}$",
    "maxLength": 7,
    "example": "2070SKD"
   },
   "FieldPlateLetters": {
    "type": "string",
    "description": "Saudi plate letters in their Latin form, read left to right: 3 on vehicles, 2 on motorcycles (the plate's type decides, held by the table that stores a plate)",
    "x-field": "plate_letters",
    "pattern": "^[ABDEGHJKLNRSTUVXZ]{2,3}$",
    "maxLength": 3,
    "example": "SKD"
   },
   "FieldPlateNumber": {
    "type": "string",
    "description": "Saudi plate number (the digits)",
    "x-field": "plate_number",
    "pattern": "^[0-9]{1,4}$",
    "maxLength": 4,
    "example": "1"
   },
   "FieldPlateType": {
    "type": "string",
    "description": "Saudi vehicle plate type",
    "x-field": "plate_type",
    "enum": [
     "private_car",
     "private_light_transport",
     "private_heavy_transport",
     "private_small_bus",
     "private_large_bus",
     "public_light_transport",
     "public_heavy_transport",
     "public_small_bus",
     "public_large_bus",
     "taxi",
     "diplomatic",
     "temporary",
     "public_works",
     "export",
     "motorcycle",
     "trailer",
     "historic"
    ],
    "example": "private_car"
   },
   "FieldPostalCode": {
    "type": "string",
    "description": "Saudi postal code",
    "x-field": "postal_code",
    "pattern": "^[0-9]{5}$",
    "maxLength": 5,
    "example": "13337"
   },
   "FieldShortAddress": {
    "type": "string",
    "description": "National short address (4 letters and 4 digits)",
    "x-field": "short_address",
    "pattern": "^[A-Z]{4}[0-9]{4}$",
    "maxLength": 8,
    "example": "RAGI2929"
   },
   "FieldTin": {
    "type": "string",
    "description": "Tax identification number (ZATCA scheme TIN)",
    "x-field": "tin",
    "pattern": "^3[0-9]{9}$",
    "maxLength": 10,
    "example": "3001234567"
   },
   "FieldUnifiedNumber": {
    "type": "string",
    "description": "Unified National Number (700), replacing the CR number under the 2025 Commercial Register Law",
    "x-field": "unified_number",
    "pattern": "^7[0-9]{9}$",
    "maxLength": 10,
    "example": "7001369813"
   },
   "FieldVatNumber": {
    "type": "string",
    "description": "VAT registration number",
    "x-field": "vat_number",
    "pattern": "^3[0-9]{13}3$",
    "maxLength": 15,
    "example": "300000000000003"
   },
   "FieldVin": {
    "type": "string",
    "description": "Vehicle identification number",
    "x-field": "vin",
    "pattern": "^[A-HJ-NPR-Z0-9]{17}$",
    "maxLength": 17,
    "example": "1G4AH59H5G1183441"
   },
   "FuelEvent": {
    "type": "object",
    "required": [
     "at",
     "kind",
     "from_pct",
     "to_pct",
     "lat",
     "lon",
     "ignition"
    ],
    "properties": {
     "at": {
      "type": "string",
      "format": "date-time",
      "description": "When the level began to change.",
      "example": "2026-11-17T06:05:00Z"
     },
     "kind": {
      "type": "string",
      "enum": [
       "refuel",
       "drop"
      ],
      "example": "refuel"
     },
     "from_pct": {
      "type": "number",
      "format": "double",
      "example": 22
     },
     "to_pct": {
      "type": "number",
      "format": "double",
      "example": 96
     },
     "lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.7136
     },
     "lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.6753
     },
     "ignition": {
      "type": [
       "boolean",
       "null"
      ],
      "description": "The ignition was on at some point while the level changed; null when the device does not report it. A drop with the engine off is one the theft check keeps.",
      "example": false
     }
    }
   },
   "FuelEvents": {
    "type": "object",
    "required": [
     "vehicle_id",
     "from",
     "to",
     "data"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "from": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-10T00:00:00Z"
     },
     "to": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T00:00:00Z"
     },
     "data": {
      "type": "array",
      "description": "Newest first.",
      "items": {
       "$ref": "#/components/schemas/FuelEvent"
      }
     }
    }
   },
   "FuelType": {
    "type": "string",
    "enum": [
     "diesel",
     "gasoline_91",
     "gasoline_95",
     "gasoline_98"
    ],
    "description": "The grade a vehicle runs on, priced by listFuelPrices.",
    "example": "diesel"
   },
   "GeoJSONPoint": {
    "type": "object",
    "description": "A GeoJSON Point: the centre of a circle geofence, [longitude, latitude] in WGS 84.",
    "required": [
     "type",
     "coordinates"
    ],
    "additionalProperties": false,
    "properties": {
     "type": {
      "type": "string",
      "enum": [
       "Point"
      ],
      "example": "Point"
     },
     "coordinates": {
      "type": "array",
      "minItems": 2,
      "maxItems": 2,
      "items": {
       "type": "number",
       "format": "double"
      },
      "example": [
       46.6753,
       24.7136
      ]
     }
    }
   },
   "GeoJSONPolygon": {
    "type": "object",
    "description": "A GeoJSON Polygon: one closed outer ring of [longitude, latitude] positions in WGS 84 (first equals last), optionally followed by holes.",
    "required": [
     "type",
     "coordinates"
    ],
    "additionalProperties": false,
    "properties": {
     "type": {
      "type": "string",
      "enum": [
       "Polygon"
      ],
      "example": "Polygon"
     },
     "coordinates": {
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
       "type": "array",
       "minItems": 4,
       "maxItems": 1000,
       "items": {
        "type": "array",
        "minItems": 2,
        "maxItems": 2,
        "items": {
         "type": "number",
         "format": "double"
        }
       }
      },
      "example": [
       [
        [
         46.67,
         24.71
        ],
        [
         46.69,
         24.71
        ],
        [
         46.69,
         24.73
        ],
        [
         46.67,
         24.73
        ],
        [
         46.67,
         24.71
        ]
       ]
      ]
     }
    }
   },
   "Geofence": {
    "type": "object",
    "required": [
     "id",
     "name",
     "kind",
     "geometry",
     "radius_m",
     "speed_limit_kmh",
     "cargo_min_c",
     "cargo_max_c",
     "created_at",
     "updated_at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "Main depot"
     },
     "kind": {
      "$ref": "#/components/schemas/GeofenceKind"
     },
     "geometry": {
      "$ref": "#/components/schemas/GeofenceGeometry"
     },
     "radius_m": {
      "type": [
       "integer",
       "null"
      ],
      "description": "The circle's radius in metres; null for a polygon",
      "example": 500
     },
     "speed_limit_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Speed limit inside the geofence, km/h",
      "example": 40
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "A customer site's cargo range: new jobs to it start with it (cold chain)",
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 8
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     }
    }
   },
   "GeofenceGeometry": {
    "description": "A Polygon, or a Point that is the centre of a circle of radius_m.",
    "example": {
     "type": "Point",
     "coordinates": [
      46.6753,
      24.7136
     ]
    },
    "oneOf": [
     {
      "$ref": "#/components/schemas/GeoJSONPolygon"
     },
     {
      "$ref": "#/components/schemas/GeoJSONPoint"
     }
    ]
   },
   "GeofenceInput": {
    "type": "object",
    "required": [
     "name",
     "geometry"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Main depot"
     },
     "kind": {
      "$ref": "#/components/schemas/GeofenceKind"
     },
     "geometry": {
      "$ref": "#/components/schemas/GeofenceGeometry"
     },
     "radius_m": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 10,
      "maximum": 50000,
      "description": "Required with a Point; not allowed with a Polygon",
      "example": 500
     },
     "speed_limit_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 5,
      "maximum": 200,
      "example": 40
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 8
     }
    }
   },
   "GeofenceKind": {
    "type": "string",
    "enum": [
     "depot",
     "site",
     "customer",
     "restricted",
     "workshop",
     "fuel"
    ],
    "description": "depot: the account's own base; site: a place it works at; customer: a customer's premises; restricted: an area to keep out of; workshop: where vehicles are serviced; fuel: a fuel station",
    "example": "depot"
   },
   "GeofenceList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Geofence"
        }
       }
      }
     }
    ]
   },
   "GeofenceUpdate": {
    "type": "object",
    "description": "The fields to change. A Point geometry needs radius_m unless the geofence is already a circle.",
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Main depot"
     },
     "kind": {
      "$ref": "#/components/schemas/GeofenceKind"
     },
     "geometry": {
      "$ref": "#/components/schemas/GeofenceGeometry"
     },
     "radius_m": {
      "type": "integer",
      "minimum": 10,
      "maximum": 50000,
      "example": 750
     },
     "speed_limit_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 5,
      "maximum": 200,
      "example": 40
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 8
     }
    }
   },
   "Group": {
    "type": "object",
    "required": [
     "id",
     "name",
     "vehicle_ids",
     "created_at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "Riyadh deliveries"
     },
     "vehicle_ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Id"
      }
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     }
    }
   },
   "GroupInput": {
    "type": "object",
    "required": [
     "name"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Riyadh deliveries"
     },
     "vehicle_ids": {
      "type": "array",
      "maxItems": 1000,
      "items": {
       "$ref": "#/components/schemas/Id"
      }
     }
    }
   },
   "GroupList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Group"
        }
       }
      }
     }
    ]
   },
   "GroupPatch": {
    "type": "object",
    "additionalProperties": false,
    "minProperties": 1,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Riyadh deliveries"
     },
     "add_vehicle_ids": {
      "type": "array",
      "maxItems": 1000,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/Id"
      }
     },
     "remove_vehicle_ids": {
      "type": "array",
      "maxItems": 1000,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/Id"
      }
     }
    }
   },
   "Guardian": {
    "type": "object",
    "required": [
     "name",
     "phone_e164",
     "notify"
    ],
    "properties": {
     "name": {
      "type": [
       "string",
       "null"
      ],
      "example": "Noura Al-Qahtani"
     },
     "phone_e164": {
      "$ref": "#/components/schemas/FieldPhoneKsa"
     },
     "notify": {
      "type": "boolean",
      "example": true
     }
    }
   },
   "GuardianInput": {
    "type": "object",
    "required": [
     "phone_e164"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 120,
      "example": "Noura Al-Qahtani"
     },
     "phone_e164": {
      "$ref": "#/components/schemas/FieldPhoneKsa"
     },
     "notify": {
      "type": "boolean",
      "default": true,
      "description": "Message this guardian when the rider boards and alights",
      "example": true
     }
    }
   },
   "HealthSim": {
    "type": "object",
    "required": [
     "iccid",
     "carrier",
     "status"
    ],
    "properties": {
     "iccid": {
      "$ref": "#/components/schemas/FieldIccid"
     },
     "carrier": {
      "type": "string",
      "example": "stc"
     },
     "status": {
      "$ref": "#/components/schemas/SimStatus"
     }
    }
   },
   "Hours": {
    "type": "object",
    "description": "Days and hours in a time zone: from from_day to to_day (across the week's end when to_day comes first), from start to end each day (end 24:00 is midnight).",
    "required": [
     "from_day",
     "to_day",
     "start",
     "end",
     "time_zone"
    ],
    "additionalProperties": false,
    "properties": {
     "from_day": {
      "$ref": "#/components/schemas/Weekday"
     },
     "to_day": {
      "$ref": "#/components/schemas/Weekday"
     },
     "start": {
      "type": "string",
      "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
      "example": "07:00"
     },
     "end": {
      "type": "string",
      "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]|24:00)$",
      "example": "18:00"
     },
     "time_zone": {
      "type": "string",
      "minLength": 3,
      "maxLength": 64,
      "description": "An IANA time zone.",
      "example": "Asia/Riyadh"
     }
    }
   },
   "HoursWindow": {
    "type": "object",
    "required": [
     "from",
     "to"
    ],
    "additionalProperties": false,
    "properties": {
     "from": {
      "type": "string",
      "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
      "example": "08:00"
     },
     "to": {
      "type": "string",
      "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
      "example": "17:00"
     }
    }
   },
   "Id": {
    "type": "string",
    "format": "uuid",
    "example": "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
   },
   "ImmobilizerInput": {
    "type": "object",
    "required": [
     "action"
    ],
    "additionalProperties": false,
    "properties": {
     "action": {
      "type": "string",
      "enum": [
       "cut",
       "restore"
      ],
      "description": "cut stops the engine from starting; restore releases it.",
      "example": "cut"
     }
    }
   },
   "Job": {
    "type": "object",
    "required": [
     "id",
     "ref",
     "status",
     "route_id",
     "vehicle_id",
     "driver_id",
     "scheduled_at",
     "proof",
     "cargo_min_c",
     "cargo_max_c",
     "notes",
     "cargo",
     "pallets",
     "department_id",
     "requires_kind",
     "disposition",
     "created_at",
     "updated_at",
     "dispatched_at",
     "started_at",
     "completed_at",
     "cancelled_at",
     "stops",
     "events",
     "proofs"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "ref": {
      "type": "string",
      "pattern": "^J-[0-9]{4}-[0-9]{4}$",
      "description": "The reference shown to drivers and recipients",
      "example": "J-2611-4821"
     },
     "status": {
      "$ref": "#/components/schemas/JobStatus"
     },
     "route_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The saved route the job was made from"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "scheduled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-11-17T09:00:00Z"
     },
     "proof": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProofKind"
      },
      "example": [
       "photo",
       "otp"
      ]
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 8
     },
     "notes": {
      "type": [
       "string",
       "null"
      ],
      "example": "Deliver to the loading bay."
     },
     "cargo": {
      "type": [
       "string",
       "null"
      ],
      "example": "Dairy, chilled"
     },
     "pallets": {
      "type": [
       "integer",
       "null"
      ],
      "example": 12
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The department the job is planned for"
     },
     "requires_kind": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ]
     },
     "disposition": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/CargoDisposition"
       },
       {
        "type": "null"
       }
      ],
      "description": "What the receiver did with the load after a breach"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "dispatched_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "started_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "The first arrival at a stop"
     },
     "completed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When the job completed or failed"
     },
     "cancelled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "stops": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/JobStop"
      }
     },
     "events": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/JobEvent"
      }
     },
     "proofs": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/StopProof"
      }
     }
    }
   },
   "JobEvent": {
    "type": "object",
    "required": [
     "id",
     "stop_id",
     "code",
     "actor",
     "lat",
     "lon",
     "note",
     "at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "stop_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "code": {
      "$ref": "#/components/schemas/JobEventCode"
     },
     "actor": {
      "type": "string",
      "description": "Who acted: user:, agent:, system: or driver:",
      "example": "system:fleet"
     },
     "lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.6951
     },
     "lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.6857
     },
     "note": {
      "type": [
       "string",
       "null"
      ]
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T09:41:00Z"
     }
    }
   },
   "JobEventCode": {
    "type": "string",
    "enum": [
     "created",
     "updated",
     "dispatched",
     "arrived",
     "departed",
     "done",
     "failed",
     "skipped",
     "completed",
     "cancelled"
    ],
    "example": "arrived"
   },
   "JobInput": {
    "type": "object",
    "required": [
     "stops"
    ],
    "additionalProperties": false,
    "properties": {
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "Needed to dispatch"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "Defaults at dispatch to the vehicle's current driver"
     },
     "scheduled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-11-17T09:00:00Z"
     },
     "proof": {
      "type": "array",
      "uniqueItems": true,
      "maxItems": 3,
      "items": {
       "$ref": "#/components/schemas/ProofKind"
      },
      "example": [
       "photo",
       "otp"
      ]
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 8
     },
     "notes": {
      "type": [
       "string",
       "null"
      ],
      "maxLength": 1000,
      "example": "Deliver to the loading bay."
     },
     "cargo": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 120,
      "description": "What the job carries",
      "example": "Dairy, chilled"
     },
     "pallets": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 0,
      "maximum": 99,
      "example": 12
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The department the job is planned for (its board), whether or not it has a vehicle"
     },
     "requires_kind": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ],
      "description": "The kind of vehicle the job needs"
     },
     "stops": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
       "$ref": "#/components/schemas/Stop"
      }
     }
    }
   },
   "JobList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/JobSummary"
        }
       }
      }
     }
    ]
   },
   "JobStatus": {
    "type": "string",
    "enum": [
     "draft",
     "dispatched",
     "in_progress",
     "completed",
     "failed",
     "cancelled"
    ],
    "example": "draft"
   },
   "JobStop": {
    "type": "object",
    "required": [
     "id",
     "seq",
     "kind",
     "name",
     "lat",
     "lon",
     "radius_m",
     "contact_phone",
     "window_from",
     "window_to",
     "status",
     "eta_at",
     "arrived_at",
     "departed_at",
     "done_at",
     "service_min",
     "geofence_id"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "seq": {
      "type": "integer",
      "description": "Order in the job, from 1",
      "example": 1
     },
     "kind": {
      "$ref": "#/components/schemas/StopKind"
     },
     "name": {
      "type": "string",
      "example": "Al Olaya branch"
     },
     "lat": {
      "type": "number",
      "format": "double",
      "example": 24.6951
     },
     "lon": {
      "type": "number",
      "format": "double",
      "example": 46.6857
     },
     "radius_m": {
      "type": "integer",
      "example": 150
     },
     "contact_phone": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPhoneKsa"
       },
       {
        "type": "null"
       }
      ]
     },
     "window_from": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-11-17T09:00:00Z"
     },
     "window_to": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-11-17T11:00:00Z"
     },
     "status": {
      "$ref": "#/components/schemas/StopStatus"
     },
     "eta_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "Estimated arrival from the vehicle's position"
     },
     "arrived_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "departed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "done_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When the stop was done, failed or skipped"
     },
     "service_min": {
      "type": "integer",
      "description": "Minutes spent at the stop",
      "example": 15
     },
     "geofence_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The geofence (customer site) the stop was picked from",
      "example": "019ac0c4-8b3c-7d4e-9f5a-6b7c8d9e0f1a"
     }
    }
   },
   "JobSummary": {
    "type": "object",
    "required": [
     "id",
     "ref",
     "status",
     "vehicle_id",
     "plate_code",
     "driver_id",
     "driver",
     "scheduled_at",
     "created_at",
     "started_at",
     "completed_at",
     "cargo_min_c",
     "cargo_max_c",
     "cargo",
     "pallets",
     "department_id",
     "requires_kind",
     "first_stop",
     "last_stop",
     "disposition",
     "stop_count",
     "stops_done"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "ref": {
      "type": "string",
      "example": "J-2611-4821"
     },
     "status": {
      "$ref": "#/components/schemas/JobStatus"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "plate_code": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPlate"
       },
       {
        "type": "null"
       }
      ],
      "description": "The vehicle's plate"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "driver": {
      "type": [
       "string",
       "null"
      ],
      "description": "The driver's name",
      "example": "Faisal Al-Harbi"
     },
     "scheduled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-11-17T09:00:00Z"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "started_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "The first arrival at a stop"
     },
     "completed_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 8
     },
     "cargo": {
      "type": [
       "string",
       "null"
      ],
      "example": "Dairy, chilled"
     },
     "pallets": {
      "type": [
       "integer",
       "null"
      ],
      "example": 12
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "requires_kind": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ]
     },
     "stops": {
      "type": "array",
      "description": "The job's stops in order, with with_stops=true",
      "items": {
       "$ref": "#/components/schemas/JobStop"
      }
     },
     "first_stop": {
      "type": [
       "string",
       "null"
      ],
      "description": "The first stop's name",
      "example": "Sudair dairy plant"
     },
     "last_stop": {
      "type": [
       "string",
       "null"
      ],
      "description": "The last stop's name",
      "example": "Al Olaya branch"
     },
     "disposition": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/DispositionOutcome"
       },
       {
        "type": "null"
       }
      ]
     },
     "stop_count": {
      "type": "integer",
      "example": 4
     },
     "stops_done": {
      "type": "integer",
      "example": 1
     }
    }
   },
   "Language": {
    "type": "string",
    "enum": [
     "ar",
     "en"
    ]
   },
   "LastPosition": {
    "type": "object",
    "required": [
     "vehicle_id",
     "fix_time",
     "lat",
     "lon",
     "speed_kmh",
     "course_deg",
     "ignition",
     "moving",
     "connected",
     "last_seen_at",
     "odometer_m",
     "engine_s",
     "state_since",
     "device",
     "signals"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "fix_time": {
      "type": "string",
      "format": "date-time",
      "description": "When the device took the position (GNSS time).",
      "example": "2026-11-17T08:42:10Z"
     },
     "lat": {
      "type": "number",
      "format": "double",
      "description": "Latitude, WGS 84.",
      "example": 24.7136
     },
     "lon": {
      "type": "number",
      "format": "double",
      "description": "Longitude, WGS 84.",
      "example": 46.6753
     },
     "speed_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "example": 62
     },
     "course_deg": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Heading, degrees clockwise from north.",
      "example": 274
     },
     "ignition": {
      "type": [
       "boolean",
       "null"
      ],
      "description": "Ignition on; null when the device does not report it.",
      "example": true
     },
     "moving": {
      "type": [
       "boolean",
       "null"
      ],
      "example": true
     },
     "connected": {
      "type": "boolean",
      "description": "The device holds an open connection now.",
      "example": true
     },
     "last_seen_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the device last sent data.",
      "example": "2026-11-17T08:42:12Z"
     },
     "odometer_m": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Odometer in metres, as the device reports it.",
      "example": 128450300
     },
     "engine_s": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Total engine hours in seconds, as the device reports them.",
      "example": 4518000
     },
     "state_since": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When the current state began: moving, idling (ignition on, not moving) or parked (ignition off).",
      "example": "2026-11-17T08:31:40Z"
     },
     "device": {
      "type": "object",
      "description": "The device installed in the vehicle.",
      "required": [
       "id",
       "imei",
       "model"
      ],
      "properties": {
       "id": {
        "$ref": "#/components/schemas/Id"
       },
       "imei": {
        "$ref": "#/components/schemas/FieldImei"
       },
       "model": {
        "type": "string",
        "example": "FMC130"
       }
      }
     },
     "signals": {
      "type": "array",
      "description": "The latest value of each measurement signal the device reports (fuel_level_pct, fuel_used_l, engine_hours_h, external_voltage_v, battery_voltage_v, gsm_signal, eco_score, cargo_temp_c ...), by key.",
      "items": {
       "$ref": "#/components/schemas/SignalReading"
      }
     }
    }
   },
   "LastPositionList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/LastPosition"
        }
       }
      }
     }
    ]
   },
   "Late": {
    "type": "string",
    "enum": [
     "notify"
    ],
    "description": "Critical rules only: still notify on records that arrive late (buffered while out of coverage), marked delayed.",
    "example": "notify"
   },
   "LeaveInput": {
    "type": "object",
    "required": [
     "reason",
     "on"
    ],
    "additionalProperties": false,
    "properties": {
     "reason": {
      "$ref": "#/components/schemas/LeaveReason"
     },
     "on": {
      "type": "string",
      "format": "date",
      "description": "The last day in the account",
      "example": "2026-11-30"
     }
    }
   },
   "LeaveReason": {
    "type": "string",
    "enum": [
     "resigned",
     "dismissed",
     "contract_ended",
     "other"
    ],
    "example": "resigned"
   },
   "LimitTerm": {
    "type": "object",
    "description": "One term of a limit, which is the first of its terms that has a value: a geofence.* or vehicle.* fact, a number, or (templates only) one of the template's number parameters.",
    "additionalProperties": false,
    "properties": {
     "fact": {
      "type": "string",
      "pattern": "^(geofence|vehicle)\\.[a-z][a-z0-9_]*$",
      "maxLength": 80,
      "example": "vehicle.speed_limit_kmh"
     },
     "number": {
      "type": "number",
      "format": "double",
      "example": 100
     },
     "param": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]{0,39}$",
      "example": "limit_kmh"
     }
    }
   },
   "Media": {
    "type": "object",
    "required": [
     "id",
     "vehicle_id",
     "kind",
     "camera",
     "trigger",
     "status",
     "content_type",
     "requested_at",
     "taken_at",
     "bytes"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "kind": {
      "type": "string",
      "enum": [
       "photo",
       "clip"
      ],
      "example": "photo"
     },
     "camera": {
      "type": "string",
      "enum": [
       "front",
       "rear"
      ],
      "example": "front"
     },
     "trigger": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*$",
      "description": "The alert rule template that asked for it (crash, panic, towing), or manual for a request from the console.",
      "example": "crash"
     },
     "status": {
      "type": "string",
      "enum": [
       "requested",
       "receiving",
       "stored",
       "failed"
      ],
      "description": "stored files can be downloaded.",
      "example": "stored"
     },
     "content_type": {
      "type": "string",
      "enum": [
       "image/jpeg",
       "video/mp4"
      ],
      "example": "image/jpeg"
     },
     "requested_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:48:31Z"
     },
     "taken_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When the camera took it; null until the device reports it.",
      "example": "2026-11-17T06:48:30Z"
     },
     "bytes": {
      "type": [
       "integer",
       "null"
      ],
      "example": 184320
     }
    }
   },
   "MediaList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Media"
        }
       }
      }
     }
    ]
   },
   "Model": {
    "type": "object",
    "description": "An approved tracker model. Datasheet facts are transcribed from the manufacturer's datasheet; product holds the manufacturer's product page as published.",
    "required": [
     "id",
     "name",
     "vendor",
     "protocol",
     "summary",
     "codecs",
     "class",
     "io_ready",
     "links",
     "datasheet",
     "media",
     "product"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "FMC130"
     },
     "vendor": {
      "type": "string",
      "enum": [
       "teltonika"
      ],
      "example": "teltonika"
     },
     "protocol": {
      "type": "string",
      "enum": [
       "teltonika"
      ],
      "description": "The device protocol PING decodes.",
      "example": "teltonika"
     },
     "summary": {
      "type": "string",
      "example": "Advanced 4G tracker"
     },
     "codecs": {
      "type": "array",
      "description": "Supported codecs: data codecs and 12 for commands.",
      "items": {
       "$ref": "#/components/schemas/Codec"
      },
      "example": [
       "8E",
       "8",
       "12"
      ]
     },
     "class": {
      "type": "string",
      "enum": [
       "vehicle",
       "asset"
      ],
      "description": "vehicle: powered from the vehicle; asset: battery-powered, for trailers and equipment.",
      "example": "vehicle"
     },
     "io_ready": {
      "type": "boolean",
      "description": "Its IO elements are decoded into typed signals.",
      "example": true
     },
     "links": {
      "$ref": "#/components/schemas/CatalogLinks"
     },
     "datasheet": {
      "$ref": "#/components/schemas/Datasheet"
     },
     "media": {
      "$ref": "#/components/schemas/CatalogMedia"
     },
     "product": {
      "$ref": "#/components/schemas/ProductPage"
     }
    }
   },
   "ModelList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Model"
        }
       }
      }
     }
    ]
   },
   "NationalAddress": {
    "type": "object",
    "description": "The Saudi national address (SPL), as the CR carries it.",
    "required": [
     "building_number",
     "street_ar",
     "street_en",
     "district_ar",
     "district_en",
     "city_ar",
     "city_en",
     "postal_code",
     "additional_number"
    ],
    "additionalProperties": false,
    "properties": {
     "short_address": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldShortAddress"
       },
       {
        "type": "null"
       }
      ],
      "description": "From a national address proof, when one was sent (the CR does not carry it)"
     },
     "building_number": {
      "$ref": "#/components/schemas/FieldBuildingNumber"
     },
     "street_ar": {
      "$ref": "#/components/schemas/FieldAddressLine"
     },
     "street_en": {
      "$ref": "#/components/schemas/FieldAddressLine"
     },
     "district_ar": {
      "$ref": "#/components/schemas/FieldAddressPlace"
     },
     "district_en": {
      "$ref": "#/components/schemas/FieldAddressPlace"
     },
     "city_ar": {
      "$ref": "#/components/schemas/FieldAddressPlace"
     },
     "city_en": {
      "$ref": "#/components/schemas/FieldAddressPlace"
     },
     "postal_code": {
      "$ref": "#/components/schemas/FieldPostalCode"
     },
     "additional_number": {
      "$ref": "#/components/schemas/FieldAdditionalNumber"
     }
    }
   },
   "OperatingHours": {
    "type": "object",
    "description": "The working hours of a full day, a short day and a day in Ramadan, Asia/Riyadh.",
    "required": [
     "full",
     "short",
     "ramadan"
    ],
    "additionalProperties": false,
    "properties": {
     "full": {
      "$ref": "#/components/schemas/HoursWindow"
     },
     "short": {
      "$ref": "#/components/schemas/HoursWindow"
     },
     "ramadan": {
      "$ref": "#/components/schemas/HoursWindow"
     }
    }
   },
   "OrderCode": {
    "type": "object",
    "required": [
     "code",
     "package",
     "regions"
    ],
    "additionalProperties": false,
    "properties": {
     "code": {
      "type": "string",
      "example": "FMC130KYXW01"
     },
     "package": {
      "type": [
       "string",
       "null"
      ],
      "example": "10 pcs. of FMC130 trackers | 10 pcs. of Input/output power supply cables (0.9 m)"
     },
     "regions": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "example": [
       "EU",
       "MEA"
      ]
     }
    }
   },
   "Page": {
    "type": "object",
    "description": "A page of a list. Pass next_cursor as cursor to get the next page; it is null on the last page.",
    "required": [
     "next_cursor"
    ],
    "properties": {
     "next_cursor": {
      "type": [
       "string",
       "null"
      ],
      "example": "eyJpZCI6InZlaF83S3EyIn0"
     }
    }
   },
   "ParamValue": {
    "type": "object",
    "description": "A value for one of the template's parameters: number for a number parameter, hours for an hours parameter.",
    "required": [
     "name"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]{0,39}$",
      "example": "limit_kmh"
     },
     "number": {
      "type": "number",
      "format": "double",
      "example": 100
     },
     "hours": {
      "$ref": "#/components/schemas/Hours"
     }
    }
   },
   "Position": {
    "type": "object",
    "required": [
     "lat",
     "lon"
    ],
    "properties": {
     "lat": {
      "type": "number",
      "format": "double",
      "minimum": -90,
      "maximum": 90,
      "example": 24.7136
     },
     "lon": {
      "type": "number",
      "format": "double",
      "minimum": -180,
      "maximum": 180,
      "example": 46.6753
     }
    }
   },
   "Problem": {
    "type": "object",
    "description": "RFC 9457 problem details. code is stable and machine-readable; detail is for people.",
    "required": [
     "type",
     "title",
     "status",
     "code"
    ],
    "properties": {
     "type": {
      "type": "string",
      "description": "The problem type: /problems/{code}, relative to the API host",
      "example": "/problems/not_found"
     },
     "title": {
      "type": "string",
      "example": "Not found"
     },
     "status": {
      "type": "integer",
      "example": 404
     },
     "code": {
      "type": "string",
      "example": "not_found"
     },
     "detail": {
      "type": "string",
      "example": "No vehicle veh_7Kq2 in this account."
     },
     "errors": {
      "type": "array",
      "description": "Field errors, for validation problems.",
      "items": {
       "type": "object",
       "required": [
        "field",
        "message"
       ],
       "properties": {
        "field": {
         "type": "string",
         "example": "plate"
        },
        "message": {
         "type": "string",
         "example": "is required"
        }
       }
      }
     }
    }
   },
   "ProductCopy": {
    "type": "object",
    "description": "Headline copy.",
    "required": [
     "name",
     "type",
     "hero",
     "meta",
     "option",
     "eol"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "example": "FMC130"
     },
     "type": {
      "type": "string",
      "example": "product"
     },
     "hero": {
      "type": [
       "string",
       "null"
      ],
      "example": "Advanced 4G LTE Cat 1 tracker with flexible inputs"
     },
     "meta": {
      "type": [
       "string",
       "null"
      ],
      "example": "FMC130 is a 4G LTE Cat 1 tracker with a backup battery for fleet management."
     },
     "option": {
      "type": [
       "string",
       "null"
      ],
      "example": "4G"
     },
     "eol": {
      "type": "boolean",
      "description": "The manufacturer has ended the product.",
      "example": false
     }
    }
   },
   "ProductPage": {
    "type": "object",
    "description": "The manufacturer's product page as published: headline copy, specification table, media and order codes.",
    "required": [
     "source",
     "product",
     "spec",
     "media",
     "order_codes"
    ],
    "additionalProperties": false,
    "properties": {
     "source": {
      "$ref": "#/components/schemas/ProductSource"
     },
     "product": {
      "$ref": "#/components/schemas/ProductCopy"
     },
     "spec": {
      "type": "array",
      "description": "The specification table: its sections in page order, each with its rows, as published.",
      "items": {
       "$ref": "#/components/schemas/SpecSection"
      }
     },
     "media": {
      "$ref": "#/components/schemas/CatalogMedia"
     },
     "order_codes": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/OrderCode"
      }
     }
    }
   },
   "ProductSource": {
    "type": "object",
    "required": [
     "url",
     "captured_on",
     "vendor_updated"
    ],
    "additionalProperties": false,
    "properties": {
     "url": {
      "type": "string",
      "format": "uri",
      "example": "https://www.teltonika-gps.com/products/trackers/advanced/fmc130"
     },
     "captured_on": {
      "type": "string",
      "format": "date",
      "description": "When PING captured the page.",
      "example": "2026-11-17"
     },
     "vendor_updated": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When the manufacturer last changed the page.",
      "example": "2026-10-05T11:21:13.439Z"
     }
    }
   },
   "ProofKind": {
    "type": "string",
    "enum": [
     "photo",
     "signature",
     "otp"
    ],
    "description": "What the driver must collect to complete a stop"
   },
   "RecordedUse": {
    "type": "string",
    "enum": [
     "company_car",
     "car_rental",
     "personal",
     "light_noncommercial",
     "exempt_heavy",
     "public_works",
     "heavy_for_hire",
     "heavy_own_goods",
     "heavy_noncommercial",
     "light_for_hire",
     "light_own_goods",
     "goods_vehicle_rental",
     "vehicle_carrying_towing",
     "educational",
     "staff_bus",
     "city_bus",
     "charter_bus",
     "intercity_bus",
     "international_bus",
     "bus_rental",
     "taxi",
     "motorcycle_delivery",
     "motorcycle_rental",
     "other",
     "unset"
    ],
    "description": "unset: registered before uses were recorded; set it with updateVehicle.",
    "example": "light_own_goods"
   },
   "RegisteredField": {
    "type": "string",
    "enum": [
     "plate",
     "vin",
     "kind",
     "use",
     "make",
     "model",
     "year"
    ],
    "description": "A vehicle's registered field: PING's, changed only by an approved request (ADR 32).",
    "example": "vin"
   },
   "RegisteredInput": {
    "type": "object",
    "additionalProperties": false,
    "minProperties": 1,
    "description": "The registered fields asked. A change gives only those it asks for (null clears one; plate and use cannot be cleared); an addition gives every one.",
    "properties": {
     "plate": {
      "$ref": "#/components/schemas/VehiclePlate"
     },
     "vin": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldVin"
       },
       {
        "type": "null"
       }
      ]
     },
     "kind": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ]
     },
     "use": {
      "$ref": "#/components/schemas/VehicleUse"
     },
     "make": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 60,
      "example": "Toyota"
     },
     "model": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 60,
      "example": "Hilux"
     },
     "year": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 1980,
      "maximum": 2100,
      "example": 2024
     }
    }
   },
   "RegisteredValues": {
    "type": "object",
    "description": "A vehicle's registered fields (null: not recorded, or not asked when read beside the fields asked).",
    "required": [
     "plate",
     "plate_code",
     "vin",
     "kind",
     "use",
     "make",
     "model",
     "year"
    ],
    "properties": {
     "plate": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehiclePlate"
       },
       {
        "type": "null"
       }
      ]
     },
     "plate_code": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPlate"
       },
       {
        "type": "null"
       }
      ]
     },
     "vin": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldVin"
       },
       {
        "type": "null"
       }
      ]
     },
     "kind": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ]
     },
     "use": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/RecordedUse"
       },
       {
        "type": "null"
       }
      ]
     },
     "make": {
      "type": [
       "string",
       "null"
      ],
      "example": "Toyota"
     },
     "model": {
      "type": [
       "string",
       "null"
      ],
      "example": "Hilux"
     },
     "year": {
      "type": [
       "integer",
       "null"
      ],
      "example": 2024
     }
    }
   },
   "RemovedContact": {
    "type": "object",
    "required": [
     "id",
     "phone",
     "user_id",
     "language",
     "whatsapp_opt_in",
     "opt_in_how",
     "opt_in_at",
     "opt_out_at",
     "created_at",
     "removed_at",
     "removed_by"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The contact's id as it was.",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "phone": {
      "$ref": "#/components/schemas/FieldPhone"
     },
     "user_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": null
     },
     "language": {
      "type": "string",
      "enum": [
       "ar",
       "en"
      ],
      "example": "ar"
     },
     "whatsapp_opt_in": {
      "type": "boolean",
      "description": "Whether it had opted in when removed.",
      "example": true
     },
     "opt_in_how": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "whatsapp",
       "form",
       "call",
       "contract",
       null
      ],
      "example": "form"
     },
     "opt_in_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": "2026-09-02T09:25:00Z"
     },
     "opt_out_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "example": null
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-09-02T09:25:00Z"
     },
     "removed_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-30T10:00:00Z"
     },
     "removed_by": {
      "type": "string",
      "description": "Who removed it, as the gateways name the caller: user:<id>, user:apikey/<id> or agent:<name>.",
      "example": "user:0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     }
    }
   },
   "RemovedContactList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/RemovedContact"
        }
       }
      }
     }
    ]
   },
   "ReportFormat": {
    "type": "string",
    "enum": [
     "pdf",
     "xlsx"
    ],
    "description": "pdf, or xlsx for Excel.",
    "example": "pdf"
   },
   "ReportInput": {
    "type": "object",
    "required": [
     "kind",
     "period",
     "recipients"
    ],
    "additionalProperties": false,
    "properties": {
     "kind": {
      "$ref": "#/components/schemas/ReportKind"
     },
     "period": {
      "$ref": "#/components/schemas/ReportPeriod"
     },
     "vehicle_ids": {
      "type": "array",
      "maxItems": 500,
      "uniqueItems": true,
      "description": "Vehicles to include. With neither vehicle_ids nor group_ids, every vehicle the key can see.",
      "items": {
       "type": "string",
       "format": "uuid"
      },
      "example": [
       "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
      ]
     },
     "group_ids": {
      "type": "array",
      "maxItems": 50,
      "uniqueItems": true,
      "description": "Groups whose vehicles to include, limited to the vehicles the key can see.",
      "items": {
       "type": "string",
       "format": "uuid"
      },
      "example": [
       "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8d"
      ]
     },
     "format": {
      "$ref": "#/components/schemas/ReportFormat"
     },
     "language": {
      "$ref": "#/components/schemas/Language"
     },
     "recipients": {
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
       "$ref": "#/components/schemas/ReportRecipient"
      },
      "example": [
       {
        "email": "operations@example.com.sa"
       },
       {
        "contact_id": "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
       }
      ]
     }
    }
   },
   "ReportKind": {
    "type": "string",
    "enum": [
     "fleet_summary",
     "trips",
     "alarms",
     "daily_stats"
    ],
    "description": "fleet_summary: totals and distance per day and per vehicle; trips: each trip with its stops; alarms: alarms raised and how they were handled; daily_stats: distance, driving and idle hours per vehicle per day.",
    "example": "fleet_summary"
   },
   "ReportPeriod": {
    "type": "object",
    "description": "Calendar days in Asia/Riyadh, both inclusive. At most 366 days, within the last five years, and not after today.",
    "required": [
     "from",
     "to"
    ],
    "additionalProperties": false,
    "properties": {
     "from": {
      "type": "string",
      "format": "date",
      "example": "2026-11-09"
     },
     "to": {
      "type": "string",
      "format": "date",
      "example": "2026-11-15"
     }
    }
   },
   "ReportRecipient": {
    "type": "object",
    "description": "Exactly one of email (the report as an attachment) or contact_id (a WhatsApp contact of the account who has opted in).",
    "additionalProperties": false,
    "properties": {
     "email": {
      "$ref": "#/components/schemas/FieldEmail"
     },
     "contact_id": {
      "type": "string",
      "format": "uuid",
      "description": "A contact of the account (accounts API).",
      "example": "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
     }
    }
   },
   "ReportRequest": {
    "type": "object",
    "description": "A report request. It starts queued, is rendered, then sent to every recipient.",
    "required": [
     "id",
     "kind",
     "period",
     "vehicle_ids",
     "group_ids",
     "format",
     "language",
     "recipients",
     "status",
     "created_at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "kind": {
      "$ref": "#/components/schemas/ReportKind"
     },
     "period": {
      "$ref": "#/components/schemas/ReportPeriod"
     },
     "vehicle_ids": {
      "type": "array",
      "items": {
       "type": "string",
       "format": "uuid"
      }
     },
     "group_ids": {
      "type": "array",
      "items": {
       "type": "string",
       "format": "uuid"
      }
     },
     "format": {
      "$ref": "#/components/schemas/ReportFormat"
     },
     "language": {
      "$ref": "#/components/schemas/Language"
     },
     "recipients": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ReportRecipient"
      }
     },
     "status": {
      "type": "string",
      "enum": [
       "queued",
       "rendering",
       "sent",
       "failed"
      ],
      "example": "queued"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-16T05:30:00Z"
     }
    }
   },
   "RequestFileInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "name",
     "content_type",
     "data"
    ],
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "pattern": "^\\S(.*\\S)?$",
      "example": "istimara.pdf"
     },
     "content_type": {
      "type": "string",
      "enum": [
       "application/pdf",
       "image/jpeg",
       "image/png"
      ]
     },
     "data": {
      "type": "string",
      "maxLength": 7000000,
      "description": "The file, base64 (at most [service.requests] max_file_bytes decoded; the request at most max_request_bytes)"
     }
    }
   },
   "Resolution": {
    "type": "string",
    "enum": [
     "actioned",
     "false_positive"
    ],
    "example": "actioned"
   },
   "RetireInput": {
    "type": "object",
    "required": [
     "reason"
    ],
    "additionalProperties": false,
    "properties": {
     "reason": {
      "$ref": "#/components/schemas/RetireReason"
     },
     "note": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 200,
      "example": "Sold to the dealer with 412,000 km"
     }
    }
   },
   "RetireReason": {
    "type": "string",
    "enum": [
     "sold",
     "scrapped",
     "written_off",
     "returned",
     "other"
    ],
    "example": "sold"
   },
   "Rider": {
    "type": "object",
    "required": [
     "id",
     "name",
     "card_id",
     "route_id",
     "guardians",
     "active",
     "created_at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "Sara Al-Qahtani"
     },
     "card_id": {
      "type": "string",
      "example": "04A1B2C3D4"
     },
     "route_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "guardians": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Guardian"
      }
     },
     "active": {
      "type": "boolean",
      "example": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     }
    }
   },
   "RiderInput": {
    "type": "object",
    "required": [
     "name",
     "card_id"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Sara Al-Qahtani"
     },
     "card_id": {
      "type": "string",
      "pattern": "^[0-9A-Za-z]{1,32}$",
      "description": "The card id as the reader reports it (hex), unique in the account",
      "example": "04A1B2C3D4"
     },
     "route_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "guardians": {
      "type": "array",
      "maxItems": 5,
      "items": {
       "$ref": "#/components/schemas/GuardianInput"
      }
     }
    }
   },
   "RiderList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Rider"
        }
       }
      }
     }
    ]
   },
   "RiderPatch": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Sara Al-Qahtani"
     },
     "card_id": {
      "type": "string",
      "pattern": "^[0-9A-Za-z]{1,32}$",
      "description": "A replaced card, as the reader reports it (hex), unique in the account",
      "example": "04A1B2C3D5"
     },
     "route_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "guardians": {
      "type": "array",
      "maxItems": 5,
      "items": {
       "$ref": "#/components/schemas/GuardianInput"
      }
     },
     "active": {
      "type": "boolean",
      "description": "false when the rider no longer rides",
      "example": false
     }
    }
   },
   "RiderRun": {
    "type": "object",
    "required": [
     "vehicle_id",
     "plate_code",
     "trip_key",
     "first_at",
     "last_at",
     "unknown_cards",
     "riders"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "plate_code": {
      "$ref": "#/components/schemas/FieldPlate"
     },
     "trip_key": {
      "type": "string",
      "description": "The vehicle trip (ignition on to off) the taps belong to"
     },
     "first_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:42:10Z"
     },
     "last_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T07:21:40Z"
     },
     "unknown_cards": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Cards tapped that no active rider holds",
      "example": [
       "04FF00AA"
      ]
     },
     "riders": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/RiderRunRider"
      }
     }
    }
   },
   "RiderRunList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/RiderRun"
        }
       }
      }
     }
    ]
   },
   "RiderRunRider": {
    "type": "object",
    "required": [
     "rider_id",
     "rider",
     "boarded_at",
     "alighted_at"
    ],
    "properties": {
     "rider_id": {
      "$ref": "#/components/schemas/Id"
     },
     "rider": {
      "type": "string",
      "example": "Sara Al-Qahtani"
     },
     "boarded_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:42:10Z"
     },
     "alighted_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "The tap off after the rider's last board; null when they never tapped off"
     }
    }
   },
   "RiderTap": {
    "type": "object",
    "required": [
     "id",
     "at",
     "kind",
     "vehicle_id",
     "plate_code",
     "rider_id",
     "rider",
     "card_id",
     "trip_key",
     "lat",
     "lon"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:42:10Z"
     },
     "kind": {
      "type": "string",
      "enum": [
       "board",
       "alight",
       "unknown"
      ],
      "description": "unknown: a card no active rider holds",
      "example": "board"
     },
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "plate_code": {
      "$ref": "#/components/schemas/FieldPlate"
     },
     "rider_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "rider": {
      "type": [
       "string",
       "null"
      ],
      "description": "The rider's name",
      "example": "Sara Al-Qahtani"
     },
     "card_id": {
      "type": "string",
      "example": "04A1B2C3D4"
     },
     "trip_key": {
      "type": "string",
      "description": "The vehicle trip (ignition on to off) the tap belongs to"
     },
     "lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.7136
     },
     "lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.6753
     }
    }
   },
   "RiderTapList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/RiderTap"
        }
       }
      }
     }
    ]
   },
   "RoleInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "role"
    ],
    "properties": {
     "role": {
      "type": "string",
      "enum": [
       "owner",
       "manager",
       "viewer",
       "driver"
      ],
      "example": "viewer"
     },
     "data_scope": {
      "type": "string",
      "enum": [
       "customer",
       "department_tree",
       "department"
      ],
      "example": "department"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     }
    }
   },
   "Route": {
    "type": "object",
    "required": [
     "id",
     "name",
     "vehicle_id",
     "driver_id",
     "stops",
     "created_at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "Morning school run"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "stops": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/RouteStop"
      }
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     }
    }
   },
   "RouteInput": {
    "type": "object",
    "required": [
     "name",
     "stops"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Morning school run"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "stops": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
       "$ref": "#/components/schemas/Stop"
      }
     }
    }
   },
   "RouteList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Route"
        }
       }
      }
     }
    ]
   },
   "RoutePatch": {
    "type": "object",
    "additionalProperties": false,
    "minProperties": 1,
    "properties": {
     "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "example": "Morning school run"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "stops": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
       "$ref": "#/components/schemas/Stop"
      }
     }
    }
   },
   "RouteRun": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "scheduled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "Defaults to unscheduled (now)",
      "example": "2026-11-18T06:30:00Z"
     },
     "dispatch": {
      "type": "boolean",
      "default": false,
      "description": "Dispatch the job at once",
      "example": true
     }
    }
   },
   "RouteStop": {
    "type": "object",
    "required": [
     "seq",
     "kind",
     "name",
     "lat",
     "lon",
     "radius_m",
     "contact_phone",
     "window_from",
     "window_to",
     "service_min",
     "geofence_id"
    ],
    "properties": {
     "seq": {
      "type": "integer",
      "description": "Order in the route, from 1",
      "example": 1
     },
     "kind": {
      "$ref": "#/components/schemas/StopKind"
     },
     "name": {
      "type": "string",
      "example": "Al Olaya branch"
     },
     "lat": {
      "type": "number",
      "format": "double",
      "example": 24.6951
     },
     "lon": {
      "type": "number",
      "format": "double",
      "example": 46.6857
     },
     "radius_m": {
      "type": "integer",
      "example": 150
     },
     "contact_phone": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPhoneKsa"
       },
       {
        "type": "null"
       }
      ]
     },
     "window_from": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "window_to": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "service_min": {
      "type": "integer",
      "example": 15
     },
     "geofence_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     }
    }
   },
   "Rule": {
    "type": "object",
    "required": [
     "id",
     "name",
     "template",
     "overrides",
     "definition",
     "scope_kind",
     "scope_id",
     "enabled",
     "created_at",
     "updated_at"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "019ac0c5-1b2c-7d3e-8f4a-5b6c7d8e9f0a"
     },
     "name": {
      "type": [
       "string",
       "null"
      ],
      "example": "Highway overspeed"
     },
     "template": {
      "type": [
       "string",
       "null"
      ],
      "description": "The built-in template the rule is made from; null for a custom rule.",
      "example": "overspeed"
     },
     "overrides": {
      "description": "A template rule's overrides; null for a custom rule.",
      "oneOf": [
       {
        "$ref": "#/components/schemas/RuleOverrides"
       },
       {
        "type": "null"
       }
      ]
     },
     "definition": {
      "description": "A custom rule's definition; null for a template rule.",
      "oneOf": [
       {
        "$ref": "#/components/schemas/RuleDefinition"
       },
       {
        "type": "null"
       }
      ]
     },
     "scope_kind": {
      "$ref": "#/components/schemas/ScopeKind"
     },
     "scope_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The department (group), vehicle or geofence id; null for the whole account.",
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     "enabled": {
      "type": "boolean",
      "example": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     }
    }
   },
   "RuleDefinition": {
    "type": "object",
    "description": "A custom rule: declarative, no scripting. It fires on the rising edge per vehicle once the conditions hold for hold_s, at most once per min_gap_s per vehicle.",
    "required": [
     "when",
     "hold_s",
     "min_gap_s",
     "severity",
     "actions"
    ],
    "additionalProperties": false,
    "properties": {
     "when": {
      "type": "array",
      "minItems": 1,
      "maxItems": 10,
      "items": {
       "$ref": "#/components/schemas/Condition"
      }
     },
     "limit": {
      "type": "array",
      "maxItems": 5,
      "description": "The threshold a condition with limit true compares with: the first term that has a value. Required when a condition uses it.",
      "items": {
       "$ref": "#/components/schemas/LimitTerm"
      }
     },
     "schedule": {
      "$ref": "#/components/schemas/Schedule"
     },
     "hold_s": {
      "type": "integer",
      "minimum": 0,
      "maximum": 604800,
      "description": "Seconds the conditions must hold before the rule fires.",
      "example": 30
     },
     "min_gap_s": {
      "type": "integer",
      "minimum": 0,
      "maximum": 604800,
      "description": "Minimum seconds between two firings on the same vehicle.",
      "example": 600
     },
     "severity": {
      "$ref": "#/components/schemas/Severity"
     },
     "actions": {
      "type": "array",
      "minItems": 1,
      "maxItems": 2,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/Action"
      },
      "example": [
       "alarm",
       "notify"
      ]
     },
     "duty": {
      "$ref": "#/components/schemas/Duty"
     },
     "late": {
      "$ref": "#/components/schemas/Late"
     }
    }
   },
   "RuleInput": {
    "type": "object",
    "required": [
     "scope_kind"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "maxLength": 120,
      "example": "Highway overspeed"
     },
     "template": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]{0,39}$",
      "description": "A built-in template id. Give template or definition.",
      "example": "overspeed"
     },
     "overrides": {
      "$ref": "#/components/schemas/RuleOverrides"
     },
     "definition": {
      "$ref": "#/components/schemas/RuleDefinition"
     },
     "scope_kind": {
      "$ref": "#/components/schemas/ScopeKind"
     },
     "scope_id": {
      "type": "string",
      "format": "uuid",
      "description": "The department (group), vehicle or geofence id; required for group, vehicle and geofence, omitted for customer.",
      "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     "enabled": {
      "type": "boolean",
      "default": true,
      "example": true
     }
    }
   },
   "RuleList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Rule"
        }
       }
      }
     }
    ]
   },
   "RuleOverrides": {
    "type": "object",
    "description": "Changes to a template's defaults. Omitted fields keep the template's values.",
    "additionalProperties": false,
    "properties": {
     "params": {
      "type": "array",
      "maxItems": 20,
      "description": "Values for the template's parameters, one per name.",
      "items": {
       "$ref": "#/components/schemas/ParamValue"
      }
     },
     "hold_s": {
      "type": "integer",
      "minimum": 0,
      "maximum": 604800,
      "description": "Seconds the conditions must hold before the rule fires.",
      "example": 60
     },
     "min_gap_s": {
      "type": "integer",
      "minimum": 0,
      "maximum": 604800,
      "description": "Minimum seconds between two firings on the same vehicle.",
      "example": 900
     },
     "severity": {
      "$ref": "#/components/schemas/Severity"
     },
     "actions": {
      "type": "array",
      "minItems": 1,
      "maxItems": 2,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/Action"
      },
      "example": [
       "alarm"
      ]
     },
     "duty": {
      "$ref": "#/components/schemas/Duty"
     }
    }
   },
   "RuleUpdate": {
    "type": "object",
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "maxLength": 120,
      "description": "An empty name clears it.",
      "example": "Highway overspeed"
     },
     "overrides": {
      "$ref": "#/components/schemas/RuleOverrides"
     },
     "definition": {
      "$ref": "#/components/schemas/RuleDefinition"
     },
     "scope_kind": {
      "$ref": "#/components/schemas/ScopeKind"
     },
     "scope_id": {
      "type": "string",
      "format": "uuid",
      "description": "Give with scope_kind (omitted for customer).",
      "example": "019ac0c3-5e0d-7f2a-8b1c-3d4e5f6a7b8c"
     },
     "enabled": {
      "type": "boolean",
      "example": false
     }
    }
   },
   "Schedule": {
    "type": "object",
    "description": "When a custom rule applies: inside or outside the hours, or (hours null) the account's operating calendar: its operating week and hours (accounts), Ramadan's hours and the Kingdom's holidays (closed).",
    "required": [
     "mode",
     "hours"
    ],
    "additionalProperties": false,
    "properties": {
     "mode": {
      "$ref": "#/components/schemas/ScheduleMode"
     },
     "hours": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/Hours"
       },
       {
        "type": "null"
       }
      ]
     }
    }
   },
   "ScheduleMode": {
    "type": "string",
    "enum": [
     "inside",
     "outside"
    ],
    "example": "outside"
   },
   "ScopeKind": {
    "type": "string",
    "enum": [
     "customer",
     "group",
     "vehicle",
     "geofence"
    ],
    "description": "What the rule applies to: the whole account, a group (an accounts department and the departments under it, by the vehicle's department in fleet), one vehicle, or every vehicle in one geofence (its geofence.* facts are that geofence's).",
    "example": "vehicle"
   },
   "Severity": {
    "type": "string",
    "enum": [
     "info",
     "warning",
     "critical"
    ],
    "example": "warning"
   },
   "SignalKey": {
    "type": "string",
    "description": "A measurement signal (infra/devices/io/signals.toml; eventual IO such as harsh driving is a driving event instead). Flags read 0 or 1.",
    "enum": [
     "fuel_used_l",
     "fuel_level_pct",
     "engine_hours_h",
     "engine_rpm",
     "fault_codes",
     "seatbelt_driver",
     "door_open",
     "cargo_temp_c",
     "cargo_temp_2_c",
     "external_voltage_v",
     "battery_voltage_v",
     "gsm_signal",
     "eco_score"
    ],
    "example": "fuel_level_pct"
   },
   "SignalReading": {
    "type": "object",
    "required": [
     "key",
     "value",
     "at"
    ],
    "properties": {
     "key": {
      "$ref": "#/components/schemas/SignalKey"
     },
     "value": {
      "type": "number",
      "format": "double",
      "example": 64
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "description": "Fix time of the record that carried it.",
      "example": "2026-11-17T08:40:00Z"
     }
    }
   },
   "SignalSeries": {
    "type": "object",
    "required": [
     "vehicle_id",
     "key",
     "step_s",
     "data"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "key": {
      "$ref": "#/components/schemas/SignalKey"
     },
     "step_s": {
      "type": "integer",
      "example": 300
     },
     "data": {
      "type": "array",
      "description": "Oldest first; steps without a reading are left out.",
      "items": {
       "type": "object",
       "required": [
        "at",
        "value"
       ],
       "properties": {
        "at": {
         "type": "string",
         "format": "date-time",
         "example": "2026-11-17T06:05:00Z"
        },
        "value": {
         "type": "number",
         "format": "double",
         "example": 64.5
        }
       }
      }
     }
    }
   },
   "SimStatus": {
    "type": "string",
    "enum": [
     "stock",
     "active",
     "suspended",
     "terminated"
    ],
    "example": "active"
   },
   "SpecRow": {
    "type": "object",
    "required": [
     "name",
     "value"
    ],
    "additionalProperties": false,
    "properties": {
     "name": {
      "type": "string",
      "example": "Position Accuracy"
     },
     "value": {
      "type": "string",
      "example": "< 2.5 m CEP"
     }
    }
   },
   "SpecSection": {
    "type": "object",
    "required": [
     "section",
     "rows"
    ],
    "additionalProperties": false,
    "properties": {
     "section": {
      "type": "string",
      "example": "GNSS"
     },
     "rows": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/SpecRow"
      }
     }
    }
   },
   "Stop": {
    "type": "object",
    "required": [
     "vehicle_id",
     "started_at",
     "ended_at",
     "duration_s",
     "lat",
     "lon",
     "ignition_on_s"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "started_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:48:30Z"
     },
     "ended_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T07:20:00Z"
     },
     "duration_s": {
      "type": "integer",
      "example": 1890
     },
     "lat": {
      "type": "number",
      "format": "double",
      "example": 24.6877
     },
     "lon": {
      "type": "number",
      "format": "double",
      "example": 46.7219
     },
     "ignition_on_s": {
      "type": "integer",
      "description": "Idling inside the stop: ignition on, seconds.",
      "example": 240
     }
    }
   },
   "StopKind": {
    "type": "string",
    "enum": [
     "pickup",
     "drop"
    ],
    "example": "drop"
   },
   "StopList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Stop"
        }
       }
      }
     }
    ]
   },
   "StopProof": {
    "type": "object",
    "required": [
     "id",
     "stop_id",
     "kind",
     "received_by",
     "at"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "stop_id": {
      "$ref": "#/components/schemas/Id"
     },
     "kind": {
      "type": "string",
      "enum": [
       "photo",
       "signature",
       "otp",
       "note"
      ],
      "description": "photo, signature: a file kept with the job; otp: the stop's code was given; note: completed without a code",
      "example": "otp"
     },
     "received_by": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who received the delivery, as the driver wrote it",
      "example": "Store manager"
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T09:48:00Z"
     }
    }
   },
   "StopStatus": {
    "type": "string",
    "enum": [
     "pending",
     "arrived",
     "done",
     "failed",
     "skipped"
    ],
    "example": "pending"
   },
   "TemplateId": {
    "type": "string",
    "pattern": "^[a-z][a-z0-9_]{0,39}$",
    "description": "A built-in template id (services/rules/templates), or custom.",
    "example": "overspeed"
   },
   "Timeline": {
    "type": "object",
    "required": [
     "vehicle_id",
     "from",
     "to",
     "events"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "from": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T00:00:00Z"
     },
     "to": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T12:00:00Z"
     },
     "events": {
      "type": "array",
      "description": "Oldest first.",
      "items": {
       "$ref": "#/components/schemas/TimelineEvent"
      }
     }
    }
   },
   "TimelineEvent": {
    "type": "object",
    "required": [
     "at",
     "kind",
     "lat",
     "lon",
     "value"
    ],
    "properties": {
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:48:30Z"
     },
     "kind": {
      "type": "string",
      "enum": [
       "ignition_on",
       "ignition_off",
       "motion_start",
       "motion_stop",
       "trip_start",
       "trip_end",
       "stop_start",
       "stop_end",
       "device_connected",
       "device_disconnected",
       "harsh_acceleration",
       "harsh_braking",
       "harsh_cornering",
       "overspeed",
       "crash",
       "towing",
       "jamming",
       "unplug"
      ],
      "example": "ignition_off"
     },
     "lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.6877
     },
     "lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.7219
     },
     "value": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "Harsh driving force in g, overspeeding speed in km/h, crash trace type; null for other kinds.",
      "example": null
     }
    }
   },
   "TrackList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Position"
        }
       }
      }
     }
    ]
   },
   "Trip": {
    "type": "object",
    "required": [
     "vehicle_id",
     "started_at",
     "ended_at",
     "start_lat",
     "start_lon",
     "end_lat",
     "end_lon",
     "distance_m",
     "driving_s",
     "idle_s",
     "max_speed_kmh",
     "harsh_acceleration",
     "harsh_braking",
     "harsh_cornering",
     "overspeed",
     "fuel_used_l",
     "driver_key",
     "driver_id"
    ],
    "properties": {
     "vehicle_id": {
      "$ref": "#/components/schemas/Id"
     },
     "started_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:10:00Z"
     },
     "ended_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T06:48:30Z"
     },
     "start_lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.7136
     },
     "start_lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.6753
     },
     "end_lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.6877
     },
     "end_lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.7219
     },
     "distance_m": {
      "type": "number",
      "format": "double",
      "example": 18420
     },
     "driving_s": {
      "type": "integer",
      "description": "Time in motion, seconds.",
      "example": 1980
     },
     "idle_s": {
      "type": "integer",
      "description": "Time with ignition on and no motion, seconds.",
      "example": 330
     },
     "max_speed_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "example": 104
     },
     "harsh_acceleration": {
      "type": "integer",
      "description": "Harsh acceleration events the device reported.",
      "example": 1
     },
     "harsh_braking": {
      "type": "integer",
      "example": 2
     },
     "harsh_cornering": {
      "type": "integer",
      "example": 0
     },
     "overspeed": {
      "type": "integer",
      "description": "Overspeeding events (the device's own speed limit).",
      "example": 1
     },
     "fuel_used_l": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "Fuel used over the trip, from the engine's fuel counter; null when the device does not report it.",
      "example": 6.4
     },
     "driver_key": {
      "type": [
       "string",
       "null"
      ],
      "description": "The driver's iButton key or card (hex) last presented during the trip; null when none was. Matches a fleet driver's ibutton_id.",
      "example": "01A2B3C4D5E6F708"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The fleet driver: whoever carried that key when the trip started, else the driver assigned to the vehicle then; null when neither is known."
     }
    }
   },
   "TripList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Trip"
        }
       }
      }
     }
    ]
   },
   "User": {
    "type": "object",
    "required": [
     "id",
     "name",
     "email",
     "phone",
     "language",
     "role",
     "data_scope",
     "department_id",
     "duties",
     "created_at",
     "deactivated_at"
    ],
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "name": {
      "type": [
       "string",
       "null"
      ],
      "example": "Fahad Al-Harbi"
     },
     "email": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldEmail"
       },
       {
        "type": "null"
       }
      ]
     },
     "phone": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPhone"
       },
       {
        "type": "null"
       }
      ],
      "description": "E.164."
     },
     "language": {
      "type": "string",
      "enum": [
       "ar",
       "en"
      ],
      "example": "ar"
     },
     "role": {
      "type": "string",
      "enum": [
       "owner",
       "manager",
       "viewer",
       "driver"
      ],
      "example": "manager"
     },
     "data_scope": {
      "type": "string",
      "enum": [
       "customer",
       "department_tree",
       "department",
       "custom"
      ],
      "description": "What the user sees: the whole account, a department and its sub-departments, one department, or a custom selection.",
      "example": "department_tree"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "duties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Duty"
      },
      "description": "The work the user handles; scheduled reports send each duty's exceptions to its holders.",
      "example": [
       "dispatch"
      ]
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-09-02T09:20:00Z"
     },
     "deactivated_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When the user left the account; null while active.",
      "example": null
     }
    }
   },
   "UserInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "role"
    ],
    "description": "At least one of email or phone.",
    "properties": {
     "name": {
      "type": "string",
      "maxLength": 120,
      "example": "Fahad Al-Harbi"
     },
     "email": {
      "type": "string",
      "format": "email",
      "example": "fahad@example.com"
     },
     "phone": {
      "type": "string",
      "description": "E.164, or a Saudi number as typed.",
      "example": "+966501234567"
     },
     "language": {
      "type": "string",
      "enum": [
       "ar",
       "en"
      ],
      "default": "ar"
     },
     "role": {
      "type": "string",
      "enum": [
       "owner",
       "manager",
       "viewer",
       "driver"
      ],
      "example": "manager"
     },
     "data_scope": {
      "type": "string",
      "enum": [
       "customer",
       "department_tree",
       "department"
      ],
      "default": "customer"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "Required unless data_scope is customer.",
      "example": "0196f1c2-7a3b-7c4d-8e5f-1a2b3c4d5e6f"
     },
     "duties": {
      "type": "array",
      "maxItems": 6,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/Duty"
      },
      "description": "The work the user handles.",
      "example": [
       "dispatch"
      ]
     }
    }
   },
   "UserList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/User"
        }
       }
      }
     }
    ]
   },
   "Vehicle": {
    "type": "object",
    "required": [
     "id",
     "plate",
     "plate_code",
     "fleet_number",
     "kind",
     "vin",
     "make",
     "model",
     "year",
     "department_id",
     "speed_limit_kmh",
     "cargo_min_c",
     "cargo_max_c",
     "tank_l",
     "fuel_type",
     "capacity_pallets",
     "use",
     "driver_id",
     "created_at",
     "updated_at",
     "retired_at",
     "retire_reason"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "plate": {
      "$ref": "#/components/schemas/VehiclePlate"
     },
     "plate_code": {
      "$ref": "#/components/schemas/FieldPlate"
     },
     "fleet_number": {
      "type": [
       "string",
       "null"
      ],
      "description": "The account's own number for the vehicle (door or fleet code), unique in the account when set",
      "example": "TRK-089"
     },
     "kind": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ]
     },
     "vin": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldVin"
       },
       {
        "type": "null"
       }
      ]
     },
     "make": {
      "type": [
       "string",
       "null"
      ],
      "example": "Toyota"
     },
     "model": {
      "type": [
       "string",
       "null"
      ],
      "example": "Hilux"
     },
     "year": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Model year",
      "example": 2024
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The account department the vehicle belongs to"
     },
     "speed_limit_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "description": "The vehicle's own speed limit for speeding alerts, km/h",
      "example": 120
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "Lowest allowed cargo temperature, °C (cold chain)",
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "description": "Highest allowed cargo temperature, °C (cold chain)",
      "example": 8
     },
     "tank_l": {
      "type": [
       "integer",
       "null"
      ],
      "description": "Fuel tank size, litres",
      "example": 400
     },
     "capacity_pallets": {
      "type": [
       "integer",
       "null"
      ],
      "description": "How many pallets the vehicle carries (dispatch load)",
      "example": 12
     },
     "fuel_type": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FuelType"
       },
       {
        "type": "null"
       }
      ]
     },
     "use": {
      "$ref": "#/components/schemas/RecordedUse"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The driver of the vehicle's current driver session"
     },
     "created_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "retired_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When it was taken out of service; null while in service"
     },
     "retire_reason": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/RetireReason"
       },
       {
        "type": "null"
       }
      ]
     }
    }
   },
   "VehicleDocument": {
    "type": "object",
    "required": [
     "type",
     "number",
     "issued_on",
     "expires_on",
     "updated_at"
    ],
    "properties": {
     "type": {
      "$ref": "#/components/schemas/VehicleDocumentType"
     },
     "number": {
      "type": [
       "string",
       "null"
      ],
      "example": "OC-2291847"
     },
     "issued_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2026-01-12"
     },
     "expires_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2027-01-11"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     }
    }
   },
   "VehicleDocumentInput": {
    "type": "object",
    "additionalProperties": false,
    "description": "The paper's fields; one left out is cleared (the body replaces the paper).",
    "properties": {
     "number": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 40,
      "example": "OC-2291847"
     },
     "issued_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2026-01-12"
     },
     "expires_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date",
      "example": "2027-01-11"
     }
    }
   },
   "VehicleDocumentType": {
    "type": "string",
    "enum": [
     "istimara",
     "operating_card",
     "insurance",
     "periodic_inspection"
    ],
    "description": "istimara: registration; operating_card: the TGA operating card; insurance: motor insurance; periodic_inspection: FAHAS.",
    "example": "operating_card"
   },
   "VehicleDocuments": {
    "type": "object",
    "required": [
     "data"
    ],
    "properties": {
     "data": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/VehicleDocument"
      }
     }
    }
   },
   "VehicleField": {
    "type": "string",
    "enum": [
     "plate",
     "fleet_number",
     "kind",
     "vin",
     "make",
     "model",
     "year",
     "speed_limit_kmh",
     "cargo_min_c",
     "cargo_max_c",
     "tank_l",
     "capacity_pallets",
     "fuel_type",
     "use"
    ],
    "description": "A vehicle field an update changed."
   },
   "VehicleHistoryEntry": {
    "type": "object",
    "description": "One thing that happened, with the fields of its kind (the others null): registered its plate_code; updated its field with from and to as text (a plate as its code); department_changed from_department_id and to_department_id; driver_assigned driver_id; document_recorded document_type and expires_on; document_deleted document_type, from (its number, when it had one), expires_on as it was and note (why); retired reason and note. An entry an approved vehicle request made names it (request_id).",
    "required": [
     "id",
     "at",
     "kind",
     "actor",
     "plate_code",
     "field",
     "from",
     "to",
     "from_department_id",
     "to_department_id",
     "driver_id",
     "document_type",
     "expires_on",
     "reason",
     "note",
     "request_id"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "at": {
      "type": "string",
      "format": "date-time",
      "example": "2026-11-17T08:30:00Z"
     },
     "kind": {
      "type": "string",
      "enum": [
       "registered",
       "updated",
       "department_changed",
       "driver_assigned",
       "document_recorded",
       "document_deleted",
       "retired"
      ],
      "example": "department_changed"
     },
     "actor": {
      "type": "string",
      "description": "Who did it (user:<id>, agent:<name>, system:<service>)",
      "example": "user:usr_4Kd9"
     },
     "plate_code": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldPlate"
       },
       {
        "type": "null"
       }
      ]
     },
     "field": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleField"
       },
       {
        "type": "null"
       }
      ]
     },
     "from": {
      "type": [
       "string",
       "null"
      ],
      "example": "100"
     },
     "to": {
      "type": [
       "string",
       "null"
      ],
      "example": "120"
     },
     "from_department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "to_department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "driver_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "document_type": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleDocumentType"
       },
       {
        "type": "null"
       }
      ]
     },
     "expires_on": {
      "type": [
       "string",
       "null"
      ],
      "format": "date"
     },
     "reason": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/RetireReason"
       },
       {
        "type": "null"
       }
      ]
     },
     "note": {
      "type": [
       "string",
       "null"
      ]
     },
     "request_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The vehicle request it applied (registered and updated by an approved request)"
     }
    }
   },
   "VehicleHistoryList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/VehicleHistoryEntry"
        }
       }
      }
     }
    ]
   },
   "VehicleKind": {
    "type": "string",
    "enum": [
     "car",
     "pickup",
     "van",
     "truck",
     "reefer",
     "tanker",
     "bus",
     "trailer"
    ],
    "description": "What kind of vehicle it is.",
    "example": "truck"
   },
   "VehicleList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/Vehicle"
        }
       }
      }
     }
    ]
   },
   "VehiclePlate": {
    "type": "object",
    "description": "A Saudi plate: its digits, its letters in their Latin form (3, or 2 on a motorcycle) and its type. Unique in the account.",
    "required": [
     "number",
     "letters",
     "type"
    ],
    "additionalProperties": false,
    "properties": {
     "number": {
      "$ref": "#/components/schemas/FieldPlateNumber"
     },
     "letters": {
      "$ref": "#/components/schemas/FieldPlateLetters"
     },
     "type": {
      "$ref": "#/components/schemas/FieldPlateType"
     }
    }
   },
   "VehicleRequest": {
    "type": "object",
    "required": [
     "id",
     "kind",
     "state",
     "vehicle_id",
     "department_id",
     "plate_code",
     "fields",
     "asked",
     "was",
     "justification",
     "files",
     "asked_by",
     "asked_at",
     "decided_by",
     "decided_at",
     "reason"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "kind": {
      "$ref": "#/components/schemas/VehicleRequestKind"
     },
     "state": {
      "$ref": "#/components/schemas/VehicleRequestState"
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "A change's vehicle; an addition's once approved"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The department an addition goes into"
     },
     "plate_code": {
      "$ref": "#/components/schemas/FieldPlate",
      "description": "The vehicle's plate when asked (an addition's plate asked)"
     },
     "fields": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/RegisteredField"
      },
      "description": "The fields asked"
     },
     "asked": {
      "$ref": "#/components/schemas/RegisteredValues",
      "description": "The values asked (null where not asked or cleared: read with fields)"
     },
     "was": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/RegisteredValues"
       },
       {
        "type": "null"
       }
      ],
      "description": "A change's values of the fields asked when asked (null for an addition)"
     },
     "justification": {
      "type": "string"
     },
     "files": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/VehicleRequestFile"
      }
     },
     "asked_by": {
      "type": "string",
      "description": "Who asked (user:<id>, ...)",
      "example": "user:019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
     },
     "asked_at": {
      "type": "string",
      "format": "date-time"
     },
     "decided_by": {
      "type": [
       "string",
       "null"
      ],
      "description": "Who approved or rejected it (PING's staff), or withdrew it"
     },
     "decided_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "reason": {
      "type": [
       "string",
       "null"
      ],
      "description": "Why it was rejected"
     }
    }
   },
   "VehicleRequestFile": {
    "type": "object",
    "required": [
     "id",
     "name",
     "content_type",
     "bytes"
    ],
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "name": {
      "type": "string",
      "example": "istimara.pdf"
     },
     "content_type": {
      "type": "string",
      "enum": [
       "application/pdf",
       "image/jpeg",
       "image/png"
      ]
     },
     "bytes": {
      "type": "integer",
      "minimum": 1
     }
    }
   },
   "VehicleRequestInput": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "kind",
     "fields",
     "justification"
    ],
    "properties": {
     "kind": {
      "$ref": "#/components/schemas/VehicleRequestKind"
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid",
      "description": "The vehicle a change is for (a change only)"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The department an added vehicle goes into (an addition only; a department-scoped caller gives one of theirs)"
     },
     "fields": {
      "$ref": "#/components/schemas/RegisteredInput"
     },
     "justification": {
      "type": "string",
      "minLength": 10,
      "maxLength": 1000,
      "description": "Why: what the papers say",
      "example": "The Istimara renewed on 2026-11-20 carries the new plate."
     },
     "files": {
      "type": "array",
      "maxItems": 3,
      "items": {
       "$ref": "#/components/schemas/RequestFileInput"
      },
      "description": "Supporting files (the Istimara, a letter), 0 to 3"
     }
    }
   },
   "VehicleRequestKind": {
    "type": "string",
    "enum": [
     "change",
     "add"
    ],
    "description": "change: a vehicle's registered fields; add: a vehicle wanted with no unit (papers only).",
    "example": "change"
   },
   "VehicleRequestList": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Page"
     },
     {
      "type": "object",
      "required": [
       "data"
      ],
      "properties": {
       "data": {
        "type": "array",
        "items": {
         "$ref": "#/components/schemas/VehicleRequest"
        }
       }
      }
     }
    ]
   },
   "VehicleRequestState": {
    "type": "string",
    "enum": [
     "pending",
     "approved",
     "rejected",
     "withdrawn"
    ],
    "example": "pending"
   },
   "VehicleUpdate": {
    "type": "object",
    "description": "The operational fields to change; null clears a field. The registered fields (plate, vin, kind, use, make, model, year) are listed only to be refused: one sent answers 400 naming requestVehicleChange (ADR 32).",
    "additionalProperties": false,
    "properties": {
     "fleet_number": {
      "type": [
       "string",
       "null"
      ],
      "minLength": 1,
      "maxLength": 20,
      "example": "TRK-089"
     },
     "department_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "speed_limit_kmh": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 20,
      "maximum": 200,
      "example": 100
     },
     "cargo_min_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 2
     },
     "cargo_max_c": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "minimum": -99,
      "maximum": 99,
      "example": 8
     },
     "tank_l": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 10,
      "maximum": 2000,
      "example": 400
     },
     "capacity_pallets": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 0,
      "maximum": 99,
      "example": 12
     },
     "fuel_type": {
      "oneOf": [
       {
        "$ref": "#/components/schemas/FuelType"
       },
       {
        "type": "null"
       }
      ]
     },
     "plate": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "allOf": [
       {
        "$ref": "#/components/schemas/VehiclePlate"
       }
      ]
     },
     "kind": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "oneOf": [
       {
        "$ref": "#/components/schemas/VehicleKind"
       },
       {
        "type": "null"
       }
      ]
     },
     "vin": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "oneOf": [
       {
        "$ref": "#/components/schemas/FieldVin"
       },
       {
        "type": "null"
       }
      ]
     },
     "make": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "type": [
       "string",
       "null"
      ],
      "maxLength": 60
     },
     "model": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "type": [
       "string",
       "null"
      ],
      "maxLength": 60
     },
     "year": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "type": [
       "integer",
       "null"
      ]
     },
     "use": {
      "deprecated": true,
      "description": "Registered: refused (400); ask with requestVehicleChange",
      "allOf": [
       {
        "$ref": "#/components/schemas/VehicleUse"
       }
      ]
     }
    }
   },
   "VehicleUse": {
    "type": "string",
    "enum": [
     "company_car",
     "car_rental",
     "personal",
     "light_noncommercial",
     "exempt_heavy",
     "public_works",
     "heavy_for_hire",
     "heavy_own_goods",
     "heavy_noncommercial",
     "light_for_hire",
     "light_own_goods",
     "goods_vehicle_rental",
     "vehicle_carrying_towing",
     "educational",
     "staff_bus",
     "city_bus",
     "charter_bus",
     "intercity_bus",
     "international_bus",
     "bus_rental",
     "taxi",
     "motorcycle_delivery",
     "motorcycle_rental",
     "other"
    ],
    "description": "What the vehicle is used for, as the Kingdom's transport regulations tell uses apart. Each fits some kinds of vehicle.",
    "example": "light_own_goods"
   },
   "WebhookAlarmCleared": {
    "type": "object",
    "description": "alarm.cleared: an alarm was closed.",
    "required": [
     "id",
     "type",
     "occurred_at",
     "data"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The event's id: the same on every endpoint and redelivery (dedupe by it); also the Ping-Event-Id header.",
      "example": "019ac0d1-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
     },
     "type": {
      "type": "string",
      "enum": [
       "alarm.cleared"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened (order by it: delivery is not ordered).",
      "example": "2026-11-17T08:30:00Z"
     },
     "data": {
      "$ref": "#/components/schemas/WebhookAlarmClearedData"
     }
    }
   },
   "WebhookAlarmClearedData": {
    "type": "object",
    "required": [
     "alarm_id",
     "rule_id",
     "vehicle_id",
     "kind",
     "severity",
     "closed_at",
     "closed_by",
     "resolution"
    ],
    "additionalProperties": false,
    "properties": {
     "alarm_id": {
      "type": "string",
      "format": "uuid"
     },
     "rule_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid"
     },
     "kind": {
      "type": "string",
      "example": "overspeed"
     },
     "severity": {
      "type": "string",
      "enum": [
       "info",
       "warning",
       "critical"
      ]
     },
     "closed_at": {
      "type": "string",
      "format": "date-time"
     },
     "closed_by": {
      "type": "string",
      "enum": [
       "person",
       "platform"
      ],
      "description": "platform: its condition cleared."
     },
     "resolution": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "actioned",
       "false_positive",
       null
      ],
      "description": "A person's resolution; null when the platform closed it."
     }
    }
   },
   "WebhookAlarmOpened": {
    "type": "object",
    "description": "alarm.opened: a rule opened an alarm.",
    "required": [
     "id",
     "type",
     "occurred_at",
     "data"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The event's id: the same on every endpoint and redelivery (dedupe by it); also the Ping-Event-Id header.",
      "example": "019ac0d1-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
     },
     "type": {
      "type": "string",
      "enum": [
       "alarm.opened"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened (order by it: delivery is not ordered).",
      "example": "2026-11-17T08:30:00Z"
     },
     "data": {
      "$ref": "#/components/schemas/WebhookAlarmOpenedData"
     }
    }
   },
   "WebhookAlarmOpenedData": {
    "type": "object",
    "required": [
     "alarm_id",
     "rule_id",
     "vehicle_id",
     "kind",
     "severity",
     "opened_at",
     "lat",
     "lon"
    ],
    "additionalProperties": false,
    "properties": {
     "alarm_id": {
      "type": "string",
      "format": "uuid",
      "description": "rules getAlarm.",
      "example": "019ac0c6-2c3d-7e4f-8a5b-6c7d8e9f0a1b"
     },
     "rule_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid"
     },
     "kind": {
      "type": "string",
      "description": "The rule's template, or custom.",
      "example": "overspeed"
     },
     "severity": {
      "type": "string",
      "enum": [
       "info",
       "warning",
       "critical"
      ]
     },
     "opened_at": {
      "type": "string",
      "format": "date-time"
     },
     "lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 24.7136
     },
     "lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double",
      "example": 46.6753
     }
    }
   },
   "WebhookAttempt": {
    "type": "object",
    "required": [
     "n",
     "at",
     "url",
     "address",
     "outcome",
     "status",
     "duration_ms",
     "error"
    ],
    "additionalProperties": false,
    "properties": {
     "n": {
      "type": "integer",
      "minimum": 1
     },
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "url": {
      "type": "string",
      "description": "The URL it went to (the endpoint's at the time)."
     },
     "address": {
      "type": [
       "string",
       "null"
      ],
      "description": "The address dialled.",
      "example": "203.0.113.7"
     },
     "outcome": {
      "type": "string",
      "enum": [
       "delivered",
       "http_error",
       "timeout",
       "unreachable",
       "refused_address"
      ],
      "description": "delivered: 2xx; http_error: another status (redirects are not followed); unreachable: DNS, connection or TLS; refused_address: the host resolved to a non-public address."
     },
     "status": {
      "type": [
       "integer",
       "null"
      ],
      "minimum": 100,
      "maximum": 599
     },
     "duration_ms": {
      "type": "integer",
      "minimum": 0
     },
     "error": {
      "type": [
       "string",
       "null"
      ],
      "description": "What went wrong, for people."
     }
    }
   },
   "WebhookDelivery": {
    "type": "object",
    "required": [
     "id",
     "endpoint_id",
     "event_id",
     "type",
     "redelivery_of",
     "state",
     "failure",
     "attempts",
     "next_attempt_at",
     "created_at",
     "done_at"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id",
      "description": "Also the Ping-Delivery-Id header."
     },
     "endpoint_id": {
      "$ref": "#/components/schemas/Id"
     },
     "event_id": {
      "$ref": "#/components/schemas/Id",
      "description": "The payload's id."
     },
     "type": {
      "$ref": "#/components/schemas/WebhookEventTypeOrTest"
     },
     "redelivery_of": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The delivery this one sends again."
     },
     "state": {
      "$ref": "#/components/schemas/WebhookDeliveryState"
     },
     "failure": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "exhausted",
       "endpoint_disabled",
       null
      ],
      "description": "Why it failed: every attempt failed, or the endpoint was disabled first."
     },
     "attempts": {
      "type": "integer",
      "minimum": 0
     },
     "next_attempt_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time",
      "description": "When it is tried next (pending only)."
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "done_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     }
    }
   },
   "WebhookDeliveryDetail": {
    "type": "object",
    "required": [
     "delivery",
     "attempt_log",
     "payload"
    ],
    "additionalProperties": false,
    "properties": {
     "delivery": {
      "$ref": "#/components/schemas/WebhookDelivery"
     },
     "payload": {
      "$ref": "#/components/schemas/WebhookPayload",
      "description": "The body each attempt sends (rendered again from the delivery's event; the signature differs per attempt)."
     },
     "attempt_log": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/WebhookAttempt"
      },
      "description": "Every attempt, first first."
     }
    }
   },
   "WebhookDeliveryList": {
    "type": "object",
    "required": [
     "data",
     "next_cursor"
    ],
    "additionalProperties": false,
    "properties": {
     "data": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/WebhookDelivery"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "WebhookDeliveryState": {
    "type": "string",
    "enum": [
     "pending",
     "succeeded",
     "failed"
    ],
    "example": "succeeded"
   },
   "WebhookEndpoint": {
    "type": "object",
    "required": [
     "id",
     "url",
     "description",
     "event_types",
     "enabled",
     "disabled_reason",
     "disabled_at",
     "secret_hint",
     "secret_rotated_at",
     "consecutive_failures",
     "created_at",
     "updated_at"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "$ref": "#/components/schemas/Id"
     },
     "url": {
      "type": "string",
      "maxLength": 2048,
      "example": "https://erp.example.com/ping/webhooks"
     },
     "description": {
      "type": [
       "string",
       "null"
      ],
      "maxLength": 200,
      "example": "ERP alarms feed"
     },
     "event_types": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/WebhookEventType"
      }
     },
     "enabled": {
      "type": "boolean"
     },
     "disabled_reason": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "owner",
       "failing",
       "account_ended",
       null
      ],
      "description": "owner: turned off by a person; failing: disabled after repeated failure; account_ended: the account left PING (its exit)."
     },
     "disabled_at": {
      "type": [
       "string",
       "null"
      ],
      "format": "date-time"
     },
     "secret_hint": {
      "type": "string",
      "description": "The secret's last four characters.",
      "example": "x7Qa"
     },
     "secret_rotated_at": {
      "type": "string",
      "format": "date-time"
     },
     "consecutive_failures": {
      "type": "integer",
      "minimum": 0,
      "description": "Deliveries in a row that failed for good."
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "WebhookEndpointInput": {
    "type": "object",
    "required": [
     "url",
     "event_types"
    ],
    "additionalProperties": false,
    "properties": {
     "url": {
      "type": "string",
      "maxLength": 2048,
      "description": "https only; no credentials, no private, loopback or link-local address.",
      "example": "https://erp.example.com/ping/webhooks"
     },
     "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "example": "ERP alarms feed"
     },
     "event_types": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/WebhookEventType"
      },
      "example": [
       "alarm.opened",
       "alarm.cleared"
      ]
     },
     "enabled": {
      "type": "boolean",
      "default": true
     }
    }
   },
   "WebhookEndpointList": {
    "type": "object",
    "required": [
     "data",
     "next_cursor"
    ],
    "additionalProperties": false,
    "properties": {
     "data": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/WebhookEndpoint"
      }
     },
     "next_cursor": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "WebhookEndpointSecret": {
    "type": "object",
    "required": [
     "endpoint",
     "secret"
    ],
    "additionalProperties": false,
    "properties": {
     "endpoint": {
      "$ref": "#/components/schemas/WebhookEndpoint"
     },
     "secret": {
      "type": "string",
      "pattern": "^whsec_[0-9A-Za-z]{32}$",
      "description": "The signing secret, shown only in this answer.",
      "example": "whsec_4fJ9kQ2mX7pL1sV8nR3tY6wZ0aB5cD7x"
     }
    }
   },
   "WebhookEndpointUpdate": {
    "type": "object",
    "additionalProperties": false,
    "minProperties": 1,
    "properties": {
     "url": {
      "type": "string",
      "maxLength": 2048,
      "example": "https://erp.example.com/ping/webhooks"
     },
     "description": {
      "type": "string",
      "maxLength": 200,
      "description": "An empty description clears it."
     },
     "event_types": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
       "$ref": "#/components/schemas/WebhookEventType"
      }
     },
     "enabled": {
      "type": "boolean"
     }
    }
   },
   "WebhookEventType": {
    "type": "string",
    "description": "An event type an endpoint can receive (docs/api.toml [webhooks] types).",
    "enum": [
     "alarm.opened",
     "alarm.cleared",
     "trip.ended",
     "geofence.entered",
     "geofence.exited",
     "job.dispatched",
     "job.started",
     "job.completed",
     "job.cancelled"
    ],
    "example": "alarm.opened"
   },
   "WebhookEventTypeOrTest": {
    "type": "string",
    "description": "A delivered event's type: a WebhookEventType, or webhook.test.",
    "enum": [
     "alarm.opened",
     "alarm.cleared",
     "trip.ended",
     "geofence.entered",
     "geofence.exited",
     "job.dispatched",
     "job.started",
     "job.completed",
     "job.cancelled",
     "webhook.test"
    ],
    "example": "trip.ended"
   },
   "WebhookGeofence": {
    "type": "object",
    "description": "geofence.entered or geofence.exited: a zone enter or exit rule fired.",
    "required": [
     "id",
     "type",
     "occurred_at",
     "data"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The event's id: the same on every endpoint and redelivery (dedupe by it); also the Ping-Event-Id header.",
      "example": "019ac0d1-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
     },
     "type": {
      "type": "string",
      "enum": [
       "geofence.entered",
       "geofence.exited"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened (order by it: delivery is not ordered).",
      "example": "2026-11-17T08:30:00Z"
     },
     "data": {
      "$ref": "#/components/schemas/WebhookGeofenceData"
     }
    }
   },
   "WebhookGeofenceData": {
    "type": "object",
    "required": [
     "geofence_id",
     "vehicle_id",
     "rule_id",
     "alarm_id",
     "at",
     "lat",
     "lon"
    ],
    "additionalProperties": false,
    "properties": {
     "geofence_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "The rule's geofence (null: the rule was deleted before it was read)."
     },
     "vehicle_id": {
      "type": "string",
      "format": "uuid"
     },
     "rule_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid"
     },
     "alarm_id": {
      "type": "string",
      "format": "uuid"
     },
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "lat": {
      "type": [
       "number",
       "null"
      ],
      "format": "double"
     },
     "lon": {
      "type": [
       "number",
       "null"
      ],
      "format": "double"
     }
    }
   },
   "WebhookJob": {
    "type": "object",
    "description": "job.*: a job changed state.",
    "required": [
     "id",
     "type",
     "occurred_at",
     "data"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The event's id: the same on every endpoint and redelivery (dedupe by it); also the Ping-Event-Id header.",
      "example": "019ac0d1-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
     },
     "type": {
      "type": "string",
      "enum": [
       "job.dispatched",
       "job.started",
       "job.completed",
       "job.cancelled"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened (order by it: delivery is not ordered).",
      "example": "2026-11-17T08:30:00Z"
     },
     "data": {
      "$ref": "#/components/schemas/WebhookJobData"
     }
    }
   },
   "WebhookJobData": {
    "type": "object",
    "required": [
     "job_id",
     "vehicle_id",
     "state"
    ],
    "additionalProperties": false,
    "properties": {
     "job_id": {
      "type": "string",
      "format": "uuid",
      "description": "fleet getJob."
     },
     "vehicle_id": {
      "type": [
       "string",
       "null"
      ],
      "format": "uuid",
      "description": "Named on dispatched and started."
     },
     "state": {
      "type": "string",
      "enum": [
       "dispatched",
       "started",
       "completed",
       "cancelled"
      ]
     }
    }
   },
   "WebhookPayload": {
    "description": "One webhook body: the payload of its type.",
    "oneOf": [
     {
      "$ref": "#/components/schemas/WebhookAlarmOpened"
     },
     {
      "$ref": "#/components/schemas/WebhookAlarmCleared"
     },
     {
      "$ref": "#/components/schemas/WebhookTripEnded"
     },
     {
      "$ref": "#/components/schemas/WebhookGeofence"
     },
     {
      "$ref": "#/components/schemas/WebhookJob"
     },
     {
      "$ref": "#/components/schemas/WebhookTest"
     }
    ],
    "discriminator": {
     "propertyName": "type",
     "mapping": {
      "alarm.opened": "#/components/schemas/WebhookAlarmOpened",
      "alarm.cleared": "#/components/schemas/WebhookAlarmCleared",
      "trip.ended": "#/components/schemas/WebhookTripEnded",
      "geofence.entered": "#/components/schemas/WebhookGeofence",
      "geofence.exited": "#/components/schemas/WebhookGeofence",
      "job.dispatched": "#/components/schemas/WebhookJob",
      "job.started": "#/components/schemas/WebhookJob",
      "job.completed": "#/components/schemas/WebhookJob",
      "job.cancelled": "#/components/schemas/WebhookJob",
      "webhook.test": "#/components/schemas/WebhookTest"
     }
    }
   },
   "WebhookPoint": {
    "type": "object",
    "required": [
     "lat",
     "lon"
    ],
    "additionalProperties": false,
    "properties": {
     "lat": {
      "type": "number",
      "format": "double",
      "example": 24.7136
     },
     "lon": {
      "type": "number",
      "format": "double",
      "example": 46.6753
     }
    }
   },
   "WebhookTest": {
    "type": "object",
    "description": "webhook.test: sent by testWebhookEndpoint.",
    "required": [
     "id",
     "type",
     "occurred_at",
     "data"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The event's id: the same on every endpoint and redelivery (dedupe by it); also the Ping-Event-Id header.",
      "example": "019ac0d1-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
     },
     "type": {
      "type": "string",
      "enum": [
       "webhook.test"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened (order by it: delivery is not ordered).",
      "example": "2026-11-17T08:30:00Z"
     },
     "data": {
      "$ref": "#/components/schemas/WebhookTestData"
     }
    }
   },
   "WebhookTestData": {
    "type": "object",
    "required": [
     "endpoint_id"
    ],
    "additionalProperties": false,
    "properties": {
     "endpoint_id": {
      "type": "string",
      "format": "uuid"
     }
    }
   },
   "WebhookTripEnded": {
    "type": "object",
    "description": "trip.ended: a vehicle's trip ended.",
    "required": [
     "id",
     "type",
     "occurred_at",
     "data"
    ],
    "additionalProperties": false,
    "properties": {
     "id": {
      "type": "string",
      "format": "uuid",
      "description": "The event's id: the same on every endpoint and redelivery (dedupe by it); also the Ping-Event-Id header.",
      "example": "019ac0d1-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
     },
     "type": {
      "type": "string",
      "enum": [
       "trip.ended"
      ]
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time",
      "description": "When it happened (order by it: delivery is not ordered).",
      "example": "2026-11-17T08:30:00Z"
     },
     "data": {
      "$ref": "#/components/schemas/WebhookTripEndedData"
     }
    }
   },
   "WebhookTripEndedData": {
    "type": "object",
    "required": [
     "vehicle_id",
     "device_id",
     "started_at",
     "ended_at",
     "start",
     "end",
     "distance_m",
     "driving_s",
     "idle_s",
     "max_speed_kmh",
     "revised",
     "replaces"
    ],
    "additionalProperties": false,
    "properties": {
     "vehicle_id": {
      "type": "string",
      "format": "uuid"
     },
     "device_id": {
      "type": "string",
      "format": "uuid"
     },
     "started_at": {
      "type": "string",
      "format": "date-time"
     },
     "ended_at": {
      "type": "string",
      "format": "date-time"
     },
     "start": {
      "$ref": "#/components/schemas/WebhookPoint"
     },
     "end": {
      "$ref": "#/components/schemas/WebhookPoint"
     },
     "distance_m": {
      "type": "number",
      "format": "double",
      "minimum": 0,
      "example": 18250.5
     },
     "driving_s": {
      "type": "integer",
      "minimum": 0
     },
     "idle_s": {
      "type": "integer",
      "minimum": 0
     },
     "max_speed_kmh": {
      "type": "integer",
      "minimum": 0
     },
     "revised": {
      "type": "boolean",
      "description": "Late records changed a trip already sent: this one takes its place."
     },
     "replaces": {
      "type": "array",
      "description": "Start times of trips sent before that this one replaces (drop them).",
      "items": {
       "type": "string",
       "format": "date-time"
      }
     }
    }
   },
   "Weekday": {
    "type": "string",
    "enum": [
     "sun",
     "mon",
     "tue",
     "wed",
     "thu",
     "fri",
     "sat"
    ],
    "example": "sun"
   }
  },
  "parameters": {
   "VehicleId": {
    "name": "vehicleId",
    "in": "path",
    "required": true,
    "schema": {
     "type": "string",
     "format": "uuid"
    },
    "example": "019ac0c4-6f1e-7a3b-9c2d-4e5f6a7b8c9d"
   },
   "DriverId": {
    "name": "driverId",
    "in": "path",
    "required": true,
    "schema": {
     "type": "string",
     "format": "uuid"
    },
    "example": "019ac0c4-7a2b-7c3d-8e4f-5a6b7c8d9e0f"
   },
   "GeofenceId": {
    "name": "geofenceId",
    "in": "path",
    "required": true,
    "schema": {
     "type": "string",
     "format": "uuid"
    },
    "example": "019ac0c4-8b3c-7d4e-9f5a-6b7c8d9e0f1a"
   },
   "JobId": {
    "name": "jobId",
    "in": "path",
    "required": true,
    "schema": {
     "type": "string",
     "format": "uuid"
    },
    "example": "019ac0c4-9c4d-7e5f-a06b-7c8d9e0f1a2b"
   },
   "StopId": {
    "name": "stopId",
    "in": "path",
    "required": true,
    "schema": {
     "type": "string",
     "format": "uuid"
    },
    "example": "019ac0c4-ad5e-7f60-b17c-8d9e0f1a2b3c"
   },
   "DriverToken": {
    "name": "X-Driver-Token",
    "in": "header",
    "required": true,
    "schema": {
     "type": "string",
     "minLength": 1,
     "maxLength": 64
    }
   },
   "Limit": {
    "name": "limit",
    "in": "query",
    "description": "Items per page, 1 to 200 (default 50).",
    "schema": {
     "type": "integer",
     "minimum": 1,
     "maximum": 200,
     "default": 50
    }
   },
   "Cursor": {
    "name": "cursor",
    "in": "query",
    "description": "The next_cursor of the previous page.",
    "schema": {
     "type": "string"
    }
   },
   "IdempotencyKey": {
    "name": "Idempotency-Key",
    "in": "header",
    "description": "A unique key per create request. A retry with the same key within 24 hours returns the first result instead of creating again.",
    "schema": {
     "type": "string",
     "maxLength": 128
    }
   }
  },
  "responses": {
   "BadRequest": {
    "description": "The request is invalid (code: invalid_request), with field errors.",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "Unauthorized": {
    "description": "The API key is missing, unknown, expired or revoked (code: unauthorized).",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "Forbidden": {
    "description": "The API key lacks the scope this operation needs (code: forbidden).",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "NotFound": {
    "description": "No such resource in this account, or outside the key's data scope (code: not_found).",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "Conflict": {
    "description": "The resource is not in a state that allows this (code: conflict), or the idempotency key is in use.",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "TooManyRequests": {
    "description": "The key's rate limit is reached (code: rate_limited). Retry after the Retry-After header's seconds.",
    "headers": {
     "Retry-After": {
      "schema": {
       "type": "integer"
      }
     }
    },
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "Unavailable": {
    "description": "A service it needs (accounts, for the departments) cannot be reached; retry shortly (code: unavailable)",
    "content": {
     "application/problem+json": {
      "schema": {
       "$ref": "#/components/schemas/Problem"
      }
     }
    }
   },
   "DriverBadRequest": {
    "description": "Missing proof or the wrong code (error: otp, proof_photo, proof_signature, invalid, kind, no_file, too_large, not_image)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/DriverError"
      }
     }
    }
   },
   "DriverNotFound": {
    "description": "An unknown job, stop or link, a wrong token, or a link expired (error: not_found)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/DriverError"
      }
     }
    }
   },
   "DriverConflict": {
    "description": "Not allowed from the stop's or the job's state (error: not_allowed, job_finished, stop_finished)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/DriverError"
      }
     }
    }
   },
   "DriverTooMany": {
    "description": "Too many requests from this address (error: too_many)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/DriverError"
      }
     }
    }
   },
   "DriverTooLarge": {
    "description": "The body is larger than the edge accepts (error: too_large)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/DriverError"
      }
     }
    }
   },
   "DriverUnavailable": {
    "description": "The edge cannot reach the service; retry shortly (error: unavailable)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/DriverError"
      }
     }
    }
   }
  },
  "securitySchemes": {
   "ApiKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "An API key issued by the account owner in the console: Authorization: Bearer ping_live_..."
   }
  }
 }
}
