> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.datatruck.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Driver

> Updates an existing driver's account info, contact details, driver type, employee status, license details, and dispatch status.

## API Url

```json theme={null}
https://{company_name}.datatruck.io/api/v1/openapi/drivers/update/{pk}/
```

Replace `{company_name}` with your company name and `{pk}` with the driver ID.

***

## Sample Request

```json theme={null}
curl --request PUT \
--url https://{company_name}.datatruck.io/api/v1/openapi/drivers/update/102/ \
--header "Authorization: Token YOUR_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "account": {
    "first_name": "John",
    "last_name": "Doe",
    "email": "john.doe@companyx.com"
  },
  "contact_number": "+1 234-567-8901",
  "driver_type": "company_driver",
  "new_employee_status": "employed",
  "status": "active",
  "is_main": true,
  "mc_number": 12345,
  "brith_date": "1990-05-15",
  "telegram_number": "@johndoe",
  "driver_license": "D1234567",
  "driver_license_issue_date": "2015-06-01",
  "driver_license_state": "TX",
  "driver_license_expiration": "2025-06-01",
  "driver_license_class": "A",
  "dispatch_status": 1
}'
```

| Field                       | Type          | Required | Description                                               |
| --------------------------- | ------------- | -------- | --------------------------------------------------------- |
| `account`                   | object        | yes      | Nested driver account info                                |
| `account.first_name`        | string        | yes      | First name of the driver                                  |
| `account.last_name`         | string        | yes      | Last name of the driver                                   |
| `account.email`             | string        | yes      | Email address                                             |
| `contact_number`            | string        | yes      | Contact number                                            |
| `driver_type`               | string        | yes      | Type of driver (`company_driver`, `owner_operator`, etc.) |
| `new_employee_status`       | string        | yes      | New employee status                                       |
| `status`                    | string        | yes      | Current status of the driver                              |
| `is_main`                   | boolean       | yes      | Is main driver                                            |
| `mc_number`                 | integer       | yes      | MC number                                                 |
| `brith_date`                | string (date) | yes      | Date of birth                                             |
| `telegram_number`           | string        | no       | Telegram username / handle                                |
| `driver_license`            | string        | no       | Driver license number                                     |
| `driver_license_issue_date` | string (date) | no       | License issue date                                        |
| `driver_license_state`      | string        | no       | License issuing state                                     |
| `driver_license_expiration` | string (date) | no       | License expiration date                                   |
| `driver_license_class`      | string        | no       | License class                                             |
| `dispatch_status`           | integer       | no       | Dispatch status code                                      |

## Sample Response

```json theme={null}
[
  {
    "id": 102,
    "account": {
      "first_name": "John",
      "last_name": "Doe",
      "full_name": "John Doe",
      "email": "john.doe@companyx.com"
    },
    "contact_number": "+1 234-567-8901",
    "driver_type": "company_driver",
    "employee_status": "employed",
    "status": "active",
    "is_main": true,
    "mc_number": 12345,
    "brith_date": "1990-05-15",
    "telegram_number": "@johndoe",
    "driver_license": "D1234567",
    "driver_license_issue_date": "2015-06-01",
    "driver_license_state": "TX",
    "driver_license_expiration": "2025-06-01",
    "driver_license_class": "A",
    "dispatch_status": 1
  }
]
```


## OpenAPI

````yaml PUT /drivers/update/{pk}/
openapi: 3.0.1
info:
  title: OpenAPI Datatruck
  description: >-
    To be able to use Datatruck OpenAPI you should create tokens from your
    dashboard. Go to your dashboard and create token with appropriate scopes and
    expiration. Expiration and scopes are optional as well as description for
    your token, but remember name is required.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://{company}.datatruck.io/api/v1/openapi/
security: []
paths:
  /drivers/update/{pk}/:
    put:
      summary: Update Driver
      description: >-
        Updates an existing driver's account info, contact details, driver type,
        employee status, license details, and dispatch status.
      operationId: updateDriver
      parameters:
        - name: pk
          in: path
          required: true
          schema:
            type: integer
          description: Unique identifier of the driver to update.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDriverRequest'
            example:
              account:
                first_name: John
                last_name: Smith
                email: jsmith@example.com
              contact_number: +1-555-0123
              driver_type: Company Driver
              new_employee_status: Active
              status: Available
              is_main: true
              mc_number: 1
              brith_date: '1985-06-15'
              telegram_number: null
              driver_license: D1234567
              driver_license_issue_date: '2020-03-10'
              driver_license_state: CA
              driver_license_expiration: '2028-03-10'
              driver_license_class: A
              dispatch_status: 1
      responses:
        '200':
          description: Driver successfully updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: success
        '400':
          description: Invalid request data.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Driver not found.
components:
  schemas:
    UpdateDriverRequest:
      type: object
      properties:
        account:
          $ref: '#/components/schemas/UpdateDriverRequestDriverAccount'
        contact_number:
          type: string
          title: Contact number
          minLength: 1
        driver_type:
          type: string
          title: Driver type
          minLength: 1
        new_employee_status:
          type: string
          title: New employee status
          minLength: 1
        status:
          type: string
          title: Status
          minLength: 1
        is_main:
          type: boolean
          title: Is main
        mc_number:
          type: integer
          title: MC number
        brith_date:
          type: string
          format: date
          title: Birth date
        telegram_number:
          type: string
          title: Telegram number
          nullable: true
        driver_license:
          type: string
          title: Driver license
          nullable: true
        driver_license_issue_date:
          type: string
          format: date
          title: Driver license issue date
          nullable: true
        driver_license_state:
          type: string
          title: Driver license state
          nullable: true
        driver_license_expiration:
          type: string
          format: date
          title: Driver license expiration
          nullable: true
        driver_license_class:
          type: string
          title: Driver license class
          nullable: true
        dispatch_status:
          type: integer
          title: Dispatch status
          nullable: true
      required:
        - account
        - contact_number
        - driver_type
        - new_employee_status
        - status
        - is_main
        - mc_number
        - brith_date
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    UpdateDriverRequestDriverAccount:
      type: object
      properties:
        first_name:
          type: string
          title: First name
          minLength: 1
        last_name:
          type: string
          title: Last name
          minLength: 1
        email:
          type: string
          format: email
          title: Email
          minLength: 1
      required:
        - first_name
        - last_name
        - email

````