# Update Mismatch Alerts

Updates trailer mismatch observation alerts for the authenticated customer.

### **Authentication**

* Include your **`Access-Token`** and **`x-api-key`** in the header of your requests.

### Permissions

The `external-api-mismatch-observations` or `admin` permission is required to access this endpoint.

### **Endpoint**

* **URL:** `https://api.genlogs.io/mismatch-observations/{mismatch-alert-id}`
* **Method:** PATCH

### **Headers**

* **Access-Token**:  (string, required): Access token obtained from the "Create Access Token" endpoint.
* **x-api-key** (string, required): The API key provided by GenLogs.

### Request body (partial update — at least one field that “counts” is required):

* `usdot` (str, int, optional): New USDOT for this single mismatch alert. `null` clears USDOT in stored criteria. Empty or whitespace-only strings are ignored (not update and not clear).
* `mc` (str, optional): New MC number for this alert; same rules as `usdot` (string/number, `null` clears, blank ignored).
* `alert_name` (str, optional): Client-facing label. `null` or blank/whitespace becomes no name (stored as null).
* `is_disabled` (bool, optional): Whether the alert is disabled.

Compared to creation

| Creation (POST)                                                         | Update (PATCH)                                                                 |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| `usdots` / `mcs` — lists of values; at least one list must be non-empty | `usdot` / `mc` — one string each (this endpoint updates one observation by id) |
| One row per list entry                                                  | Updates the row identified by `{observation_id}`                               |

Other notes

* Unknown JSON keys are rejected.
* If the body is empty, only has ignored blank `usdot`/`mc`, or no applicable fields, the API returns 400 (“no updatable fields”).
* Patching `usdot`/`mc` still runs the same validation as create; invalid combinations can return 400.

### Request Example:

```bash
curl --location 'https://api.genlogs.io/mismatch-observations/{observation-id}' \
--header 'access-token: <your-api-token>' \
--header 'x-api-key: <your-x-api-key>' \
--data-raw '{
    "usdot": "87442",
    "alert_name": "Updated API mismatch ALERT",
    "is_disabled": true
}'
```

### **Response:**

* **200 OK:** A JSON object containing the confirmation values of the updated alert.
* **400 Bad Request:** If one of the request parameters incorrect.
* **401 Unauthorized:** If the authentication credentials (Access-Token) is missing or incorrect.
* **403 Forbidden**: If the permission has not been set to your user.
* **500 Internal Server Error:** If there is an issue on the server that prevents processing the request.

### **Response Body:**

200 OK

```json
{
    "id": "{mismatch-alert-id}",
    "alert_name": "Updated API mismatch ALERT",
    "usdot": "87442",
    "mc": null,
    "is_disabled": true,
    "created_at": "2026-04-08T19:11:18.023892",
    "last_run_at": null
}
```

400 Bad Request (e.g. empty object `{}`)

```json
{
    "detail": "At least one field must be provided."
}
```

401 Forbidden

```json
{
  "detail": {
    "message": "Token is missing",
    "subcode": "TOKEN_MISSING"
  }
}
```

403 Forbidden

```json
{
    "detail": "User does not have the required permissions to access this resource"
}
```

## Update a mismatch observation

> Partial update of USDOT (\`usdot\`), MC (\`mc\`), display name (\`alert\_name\`), and/or \`is\_disabled\`. Send at least one field. Requires permission \`external-api-mismatch-observations\` or admin. Only alerts belonging to the JWT \`customer\_id\` can be updated; otherwise 403. Returns the full updated observation (same shape as list items).<br>

```json
{"openapi":"3.0.3","info":{"title":"Mismatch observation alerts (external API)","version":"1.4.0"},"servers":[{"url":"https://api.genlogs.io"}],"security":[{"Access-Token":[],"X-Api-Key":[]}],"components":{"securitySchemes":{"Access-Token":{"type":"apiKey","in":"header","name":"Access-Token"}},"schemas":{"MismatchObservationPatchRequest":{"type":"object","additionalProperties":false,"description":"At least one property must be present (after applying ignore rules). Omitted fields are left unchanged. Empty string or whitespace-only `usdot` / `mc` values are ignored (they do not clear the field). JSON `null` for `usdot` / `mc` still clears that side of the criteria when present. USDOT/MC validation matches create rules (numeric after normalization).\n","properties":{"usdot":{"type":"string","nullable":true,"description":"New USDOT value; null clears when paired with MC update rules."},"mc":{"type":"string","nullable":true,"description":"New MC value; null clears when paired with USDOT update rules."},"logos":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Trailer logos list. Pass [] or null to clear. Max list size is limited by server configuration (`MISMATCH_ALERTS_MAX_LOGOS`).\n"},"alert_name":{"type":"string","nullable":true,"description":"Display name; blank or whitespace-only is stored as null."},"is_disabled":{"type":"boolean","description":"Whether the observation is disabled."}}},"MismatchObservationItem":{"type":"object","required":["id","usdot","mc","is_disabled"],"properties":{"id":{"type":"string","format":"uuid","description":"Alert row identifier."},"alert_name":{"type":"string","nullable":true,"description":"Optional display name; may be null if not set."},"usdot":{"type":"string","nullable":true,"description":"USDOT value from stored criteria."},"mc":{"type":"string","nullable":true,"description":"MC value from stored criteria."},"logos":{"type":"array","items":{"type":"string"},"description":"Trailer logos from `logos`. Empty when not configured.","default":[]},"is_disabled":{"type":"boolean","description":"Whether this mismatch observation alert is disabled."},"created_at":{"type":"string","format":"date-time","nullable":true,"description":"Creation timestamp when available."},"last_run_at":{"type":"string","format":"date-time","nullable":true,"description":"Last run timestamp in ISO-8601 format; null when not run yet."}}}}},"paths":{"/mismatch-observations/{observation_id}":{"patch":{"summary":"Update a mismatch observation","description":"Partial update of USDOT (`usdot`), MC (`mc`), display name (`alert_name`), and/or `is_disabled`. Send at least one field. Requires permission `external-api-mismatch-observations` or admin. Only alerts belonging to the JWT `customer_id` can be updated; otherwise 403. Returns the full updated observation (same shape as list items).\n","tags":["Mismatch alerts"],"parameters":[{"name":"observation_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"Mismatch observation (alert) identifier."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MismatchObservationPatchRequest"}}}},"responses":{"200":{"description":"Full updated mismatch observation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MismatchObservationItem"}}}},"400":{"description":"Bad request – empty body, no updatable fields, invalid USDOT/MC, or validation error.\n"},"401":{"description":"Unauthorized – Invalid or missing Access-Token."},"403":{"description":"Forbidden – missing permission, or observation belongs to another customer."},"404":{"description":"Mismatch observation not found or deleted."}}}}}}
```

## The MismatchObservationPatchRequest object

```json
{"openapi":"3.0.3","info":{"title":"Mismatch observation alerts (external API)","version":"1.4.0"},"components":{"schemas":{"MismatchObservationPatchRequest":{"type":"object","additionalProperties":false,"description":"At least one property must be present (after applying ignore rules). Omitted fields are left unchanged. Empty string or whitespace-only `usdot` / `mc` values are ignored (they do not clear the field). JSON `null` for `usdot` / `mc` still clears that side of the criteria when present. USDOT/MC validation matches create rules (numeric after normalization).\n","properties":{"usdot":{"type":"string","nullable":true,"description":"New USDOT value; null clears when paired with MC update rules."},"mc":{"type":"string","nullable":true,"description":"New MC value; null clears when paired with USDOT update rules."},"logos":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Trailer logos list. Pass [] or null to clear. Max list size is limited by server configuration (`MISMATCH_ALERTS_MAX_LOGOS`).\n"},"alert_name":{"type":"string","nullable":true,"description":"Display name; blank or whitespace-only is stored as null."},"is_disabled":{"type":"boolean","description":"Whether the observation is disabled."}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.genlogs.io/alerts/mismatch-alerts/update-mismatch-alerts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
