> For the complete documentation index, see [llms.txt](https://docs.genlogs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.genlogs.io/alerts/mismatch-alerts/create-mismatch-alerts.md).

# Create Mismatch Alerts

Creates trailer mismatch observation alerts for the authenticated customer from standalone USDOT numbers, standalone MC numbers, and paired MC/USDOT records.

### **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`
* **Method:** POST

### **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:

* `usdots` (list of USDOTs, optional or required when `mcs` is not provided): list of the requested USDOT numbers to create a mismatch alert
* `mcs` (list of MCs, optional or required when `usdots` is not provided): list of the requested MC numbers to create a mismatch alert
* `pairs` (list of objects, optional): Paired MC/USDOT records. Each object creates one combined mismatch alert with both values.
  * Each `pairs` object must include:

    <pre class="language-json" data-expandable="true"><code class="lang-json"><strong>{"mc": "7894","usdot": "9637"}
    </strong></code></pre>
* `alert_name` (srt, optional): related name of the alert(s) for client use.
* `logos` (list of Logos, optional): list of the optional logos names to create a mismatch alert

### Request Example:

```bash
curl --location 'https://api.genlogs.io/mismatch-observations' \
--header 'access-token: <your-api-token>' \
--header 'x-api-key: <your-x-api-key>' \
--data-raw '{
  "usdots": ["10000", "200000", "300000"],
  "mcs": ["4000", "5000"],
  "pairs": [
    {
      "mc": "7894",
      "usdot": "9637"
    }
  ],
  "alert_name": "Custom mismatch trailer alert",
  "logos": ["logo_name1", "logo_name2"]
}'
```

### **Response:**

* `201 Created`: Returns a confirmation message and the count of created alerts.
* `400 Bad Request`: Missing or invalid request parameters.
* `401 Unauthorized`: Missing or invalid `Access-Token`.
* `403 Forbidden`: User does not have the required permission.
* `500 Internal Server Error`: Server error while processing the request.

### **Response Body:**

201 Created

```json
{
    "message": "Mismatch alerts created successfully.",
    "data": {
        "created": 4
    }
}
```

400 Bad Request

```json
{
  "detail": "At least one USDOT, MC, or pair 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"
}
```

## Create mismatch observation alerts

> Creates one alert row per standalone USDOT or MC value, and one combined row per item in \`pairs\`. At least one of \`usdots\`, \`mcs\`, or \`pairs\` must be non-empty. \`alert\_name\` is optional; when omitted or blank, stored as null. \`logos\` is optional and, when present, is normalized to lowercase, stored in \`logos\`, and used by mismatch detection. Logo matching remains case-insensitive. Unknown JSON properties are rejected.<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":{"ExternalMismatchObservationsRequest":{"type":"object","additionalProperties":false,"properties":{"usdots":{"type":"array","items":{"type":"string"},"description":"USDOT numbers (strings). Each non-empty entry creates one alert.","default":[]},"mcs":{"type":"array","items":{"type":"string"},"description":"MC numbers (strings). Each non-empty entry creates one alert.","default":[]},"pairs":{"type":"array","items":{"$ref":"#/components/schemas/MismatchObservationPairRequest"},"description":"Paired MC/USDOT identifiers. Each item creates one combined alert row with both MC and USDOT in the stored criteria.\n","default":[]},"logos":{"type":"array","nullable":true,"items":{"type":"string"},"description":"Optional trailer logos list. Each value must be a non-empty string. Values are trimmed, deduplicated, and stored in lowercase format. Matching against the logos catalog.\n"},"alert_name":{"type":"string","nullable":true,"description":"Optional display name; omitted or whitespace-only is stored as null."}}},"MismatchObservationPairRequest":{"type":"object","additionalProperties":false,"required":["mc","usdot"],"properties":{"mc":{"type":"string","minLength":1,"description":"MC number for the combined alert row."},"usdot":{"type":"string","minLength":1,"description":"USDOT number for the combined alert row."}}}}},"paths":{"/mismatch-observations":{"post":{"summary":"Create mismatch observation alerts","description":"Creates one alert row per standalone USDOT or MC value, and one combined row per item in `pairs`. At least one of `usdots`, `mcs`, or `pairs` must be non-empty. `alert_name` is optional; when omitted or blank, stored as null. `logos` is optional and, when present, is normalized to lowercase, stored in `logos`, and used by mismatch detection. Logo matching remains case-insensitive. Unknown JSON properties are rejected.\n","tags":["Mismatch alerts"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExternalMismatchObservationsRequest"}}}},"responses":{"201":{"description":"Mismatch alerts created successfully.","content":{"application/json":{"schema":{"type":"object","required":["message","data"],"properties":{"message":{"type":"string"},"data":{"type":"object","properties":{"created":{"type":"integer","description":"Number of alerts inserted."}}}}}}}},"400":{"description":"Bad request – validation error or empty usdots/mcs/pairs."},"401":{"description":"Unauthorized – Invalid or missing Access-Token."},"403":{"description":"Forbidden – missing permission."},"500":{"description":"Internal Server Error."}}}}}}
```
