---
title: "Update a defect"
method: PATCH
path: "/fleet/defects/{id}"
tags: ["Maintenance"]
---

# Update a defect

`PATCH /fleet/defects/{id}`

## Request

- Base URL: `https://api.samsara.com`
- URL: `https://api.samsara.com/fleet/defects/{id}`
- Auth: HTTP bearer

Updates a given defect. Can be used to resolve a defect by marking its `isResolved` field to `true`. 

 **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

To use this endpoint, select **Write Defects** under the Maintenance category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

## Path parameters

- `id` string, required

## Request body

- DefectPatch: Information about resolving a defect. If resolving a defect, must specify `isResolved` as `true` and `resolvedBy`.
  - `isResolved` boolean: Resolves the defect. Must be `true`.
  - `mechanicNotes` string: The mechanics notes on the defect.
  - `resolvedAtTime` string: Time when defect was resolved. Defaults to now if not provided. UTC timestamp in RFC 3339 format. Example: `2020-01-27T07:06:25Z`.
  - `resolvedBy` ResolvedBy: Information about the user who is resolving a defect.
    - `id` string, required: The Id of user who is resolving the defect.
    - `type` 'mechanic', required: The type of user who is resolving the defect. Must be "mechanic".

## Response `200`

Return the modified defect entity

- DefectResponse: A single defect.
  - `data` Defect
    - `comment` string: Comment on the defect.
    - `createdAtTime` string: Time when the defect was created. UTC timestamp in RFC 3339 format. Example: `2020-01-27T07:06:25Z`.
    - `defectType` string: The type of DVIR defect.
    - `id` string, required: ID of the defect.
    - `isResolved` boolean, required: Signifies if this defect is resolved.
    - `mechanicNotes` string: The mechanics notes on the defect.
    - `mechanicNotesUpdatedAtTime` string: Time when mechanic notes were last updated. UTC timestamp in RFC 3339 format. Example: `2020-01-27T07:06:25Z`.
    - `resolvedAtTime` string: Time when this defect was resolved. Will not be returned if the defect is unresolved. UTC timestamp in RFC 3339 format. Example: `2020-01-27T07:06:25Z`.
    - `resolvedBy` DefectResolvedBy: The person who resolved this defect. Will not be returned if the defect is unresolved.
      - `id` string: ID of the entity that resolved this defect. If the defect was resolved by a driver, this will be a Samsara Driver ID. If the defect was resolved by a mechanic, this will be the Samsara Dashboard User ID of the mechanic.
      - `name` string: Name of the person who resolved this defect.
      - `type` 'driver' | 'mechanic': Indicates whether this defect was resolved by a `driver` or a `mechanic`.
    - `trailer` object: A minified trailer object.
      - `id` string: ID of the trailer.
      - `name` string: Name of the trailer.
    - `vehicle` object: A minified vehicle object.
      - `ExternalIds` object: The [external IDs](https://developers.samsara.com/docs/external-ids) for the given object.
      - `id` string: ID of the vehicle.
      - `name` string: Name of the vehicle.

## Other responses

- `default`: Error response

---

[API](https://skmtc.dev/samsara/apis/samsara-api.md) - [All operations](https://skmtc.dev/samsara/apis/samsara-api/llms.txt) - [OpenAPI document](https://skmtc.dev/samsara/apis/samsara-api/revisions/a9e35d4999be?raw)
