Skip to main content

Update an existing vehicle

POST 

/company/vehicles/:id

Updates an existing vehicle's information including metadata and file uploads.

Objective

Enable companies to modify vehicle specifications, update documentation, and manage default vehicle settings.

Use Cases

  • Update vehicle specifications (type, cargo capabilities)
  • Replace or remove vehicle images and ITV certificates
  • Change shipping type and temperature settings
  • Set or unset vehicle as user's default

Validation Flow

flowchart TD
A[Receive Request] --> B{User Has Company?}
B -->|No| C[401 CIA_NOT_FOUND]
B -->|Yes| D{Vehicle Exists?}
D -->|No| E[404 VEHICLE_NOT_FOUND]
D -->|Yes| F{Company Owns Vehicle?}
F -->|No| G[403 CIA_NOT_OWNER]
F -->|Yes| H{shipping_type Changed?}
H -->|Yes to dry| I[Auto-remove fresh_cargo_temp]
H -->|Yes to fresh| J{fresh_cargo_temp Valid?}
J -->|No| K[400 Temp Required]
J -->|Yes| L[Update Vehicle]
H -->|No| L
I --> L
L --> M{default_vehicle = true?}
M -->|Yes| N[Update User Default]
M -->|No| O[Return Updated Vehicle]
N --> O

File Deletion

To delete an existing file (image or itv), send the field with an empty string value. The file will be removed from S3 storage and the field will be set to empty.

Example:

{
image: ,
itv:
}

Automatic Behavior

  • If shipping_type is changed to 'dry', fresh_cargo_temp is automatically removed
  • Only fields included in the request are updated; others remain unchanged
  • Files (image, itv) are excluded from automatic updates and require explicit handling

Partial Updates

You can update only specific fields. Fields not included in the request will retain their current values.

Security

This endpoint validates ownership - the vehicle must belong to the authenticated user's company.

Request

Responses

Vehicle updated successfully

Response Headers