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

# Search maintenance records

> Search maintenance records with paginated POST filters — truck or trailer, work order type, vendor, service date range, and completion status.

The Search Maintenance API endpoint allows you to search for maintenance records within the Alvys system based on various criteria such as asset type, category, status, and date range. This endpoint provides detailed information about each maintenance record that matches the search criteria, facilitating efficient management and retrieval of maintenance records.

### Request Parameters

The following parameter is required in the URL path:

| Parameter | Type   | Required | Description             |
| --------- | ------ | -------- | ----------------------- |
| version   | String | Yes      | The API version to use. |

#### Request Body

The following fields are required in the request body to filter the search results:

`<Table>`

<thead>
  <tr>
    <th>
      Parameter
    </th>

    <th>
      Type
    </th>

    <th>
      Required
    </th>

    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Page
    </td>

    <td>
      Integer
    </td>

    <td>
      Yes
    </td>

    <td>
      The page number to retrieve.
    </td>
  </tr>

  <tr>
    <td>
      PageSize
    </td>

    <td>
      Integer
    </td>

    <td>
      Yes
    </td>

    <td>
      The number of results per page.\
      PageSize must be greater than 0.
    </td>
  </tr>

  <tr>
    <td>
      TruckIds
    </td>

    <td>
      Array of Strings
    </td>

    <td>
      Conditionally
    </td>

    <td>
      A list of truck IDs to filter by. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>

  <tr>
    <td>
      TrailerIds
    </td>

    <td>
      Array of Strings
    </td>

    <td>
      Conditionally
    </td>

    <td>
      A list of trailer IDs to filter by. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>

  <tr>
    <td>
      Categories
    </td>

    <td>
      Array of Strings
    </td>

    <td>
      Conditionally
    </td>

    <td>
      A list of categories to filter by. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>

  <tr>
    <td>
      Status
    </td>

    <td>
      String
    </td>

    <td>
      Conditionally
    </td>

    <td>
      The status of the maintenance record. One of the following: `Urgent`, `Open`, `Closed`. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>

  <tr>
    <td>
      DateRange
    </td>

    <td>
      Object
    </td>

    <td>
      Conditionally
    </td>

    <td>
      The date range for the maintenance records. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>

  <tr>
    <td>
      DateRange.Start
    </td>

    <td>
      String (Date-Time)
    </td>

    <td>
      Conditionally
    </td>

    <td>
      The start date of the maintenance records range. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>

  <tr>
    <td>
      DateRange.End
    </td>

    <td>
      String (Date-Time)
    </td>

    <td>
      Conditionally
    </td>

    <td>
      The end date of the maintenance records range. This field is required if the other conditionally required fields are left empty.
    </td>
  </tr>
</tbody>

`</Table>`

#### Example CURL request

Use the Current API version number and make sure to replace the Authorization header value with your actual Bearer token for the request:

```bash theme={null}
curl --location 'https://integrations.alvys.com/api/p/v1/maintenance/search' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ....' \
--header 'Content-Type: application/json' \
--data '{
  "Page": 0,
  "PageSize": 100,
  "TruckIds": [
      "TR123456789"
  ],
  "TrailerIds": [
      ""
  ],
  "Categories": [
      "Tires"
  ],
  "Status": "Open",
  "DateRange": {
      "Start": "2021-01-23T13:36:42.021Z",
      "End": "2024-08-23T13:36:42.021Z"
  }
}'
```

### Response Parameters

The following table lists the parameters included in the response for maintenance search requests:

| Parameter                      | Type               | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                           |
| ------------------------------ | ------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Page                           | Integer            | Yes      | The current page number of the results.                                                                                                                                                                                                                                                                                                                                                                               |
| PageSize                       | Integer            | Yes      | The number of results per page.                                                                                                                                                                                                                                                                                                                                                                                       |
| Total                          | Integer            | Yes      | The total number of matching maintenance records.                                                                                                                                                                                                                                                                                                                                                                     |
| Items                          | Array of Objects   | Yes      | The list of maintenance records matching the criteria.                                                                                                                                                                                                                                                                                                                                                                |
| Items.Id                       | String             | Yes      | The unique identifier of the maintenance record.                                                                                                                                                                                                                                                                                                                                                                      |
| Items.PO                       | String             | No       | The purchase order number associated with the maintenance.                                                                                                                                                                                                                                                                                                                                                            |
| Items.Reference                | String             | No       | A reference string for the maintenance record.                                                                                                                                                                                                                                                                                                                                                                        |
| Items.RelatedAsset             | Object             | No       | Details about the related asset for the maintenance.                                                                                                                                                                                                                                                                                                                                                                  |
| Items.RelatedAsset.AssetId     | String             | No       | The unique identifier of the asset.                                                                                                                                                                                                                                                                                                                                                                                   |
| Items.RelatedAsset.AssetNumber | String             | No       | The asset number.                                                                                                                                                                                                                                                                                                                                                                                                     |
| Items.RelatedAsset.AssetType   | String             | No       | The type of asset (e.g., Truck, Trailer).                                                                                                                                                                                                                                                                                                                                                                             |
| Items.Category                 | Object             | No       | The category of the maintenance work.                                                                                                                                                                                                                                                                                                                                                                                 |
| Items.Category.Id              | String             | No       | The unique identifier of the category.                                                                                                                                                                                                                                                                                                                                                                                |
| Items.Category.Name            | String             | No       | The name of the category.                                                                                                                                                                                                                                                                                                                                                                                             |
| Items.Description              | String             | No       | A description of the maintenance work.                                                                                                                                                                                                                                                                                                                                                                                |
| Items.Comments                 | String             | No       | Additional comments or notes about the maintenance.                                                                                                                                                                                                                                                                                                                                                                   |
| Items.Amount                   | Object             | No       | The total amount for the maintenance work.                                                                                                                                                                                                                                                                                                                                                                            |
| Items.Amount.Amount            | Number             | No       | The amount value.                                                                                                                                                                                                                                                                                                                                                                                                     |
| Items.Amount.Currency          | Integer            | No       | The currency of the amount.                                                                                                                                                                                                                                                                                                                                                                                           |
| Items.RepairShop               | Object             | No       | Information about the repair shop.                                                                                                                                                                                                                                                                                                                                                                                    |
| Items.RepairShop.Id            | String             | No       | The unique identifier of the repair shop.                                                                                                                                                                                                                                                                                                                                                                             |
| Items.RepairShop.Name          | String             | No       | The name of the repair shop.                                                                                                                                                                                                                                                                                                                                                                                          |
| Items.Reminders                | Array              | No       | A list of reminders associated with the maintenance.                                                                                                                                                                                                                                                                                                                                                                  |
| Items.Reminders.id             | String             | No       | The unique identifier of the reminder.                                                                                                                                                                                                                                                                                                                                                                                |
| Items.Reminders.DueDate        | String (Date-Time) | No       | The due date for the reminder.                                                                                                                                                                                                                                                                                                                                                                                        |
| Items.CreatedAt                | String (Date-Time) | Yes      | The date and time when the maintenance record was created. For some maintenance records, the `CreatedAt` field may display `1970-01-01T00:00:00+00:00`. This placeholder represents the Unix Epoch and indicates that the original creation timestamp is unavailable. Users should interpret this as an unknown creation date, specific only to the `CreatedAt` field and not reflective of other timestamps or data. |
| Items.CreatedBy                | String             | No       | The user who created the maintenance record.                                                                                                                                                                                                                                                                                                                                                                          |
| Items.ModifiedAt               | String (Date-Time) | No       | The date and time when the maintenance record was last modified.                                                                                                                                                                                                                                                                                                                                                      |
| Items.ModifiedBy               | String             | No       | The user who last modified the maintenance record.                                                                                                                                                                                                                                                                                                                                                                    |

#### Example Response

On the right side, you can see examples of different error codes by clicking "Example" and selecting the response code.

<img src="https://mintcdn.com/alvys/MPqgFq1pceM5E4R4/images/migrated/130f30b-Sear.gif?s=92a1e50433338d269742c39a0b04dd7a" alt="" width="706" height="844" data-path="images/migrated/130f30b-Sear.gif" />

#### Rate Limits

All endpoints are subject to rate limits to protect the API from traffic spikes. For detailed information on rate limits, please refer to the [Rate Limits](#rate-limits) section.

This page is interactive, allowing you to try a request by completing the fields for the parameters below. As you fill out the parameters, the Curl command on the right side of the page will be automatically updated. Alternatively, you can directly edit the Curl command. Make sure to authorize yourself before trying a request.


## OpenAPI

````yaml POST /api/p/v{version}/maintenance/search
openapi: 3.0.1
info:
  title: Alvys
  description: >-
    Alvys provides a robust set of REST APIs to allow you to integrate Alvys
    into virtually any platform. These APIs cover most of Alvys' major product
    areas with additional endpoints being added regularly based on customer
    requests.
  contact:
    name: Alvys Support
    url: https://www.alvys.com/resources/contact/
  version: v1
servers:
  - url: https://integrations.alvys.com
    description: Public API Server
  - url: https://api.alvys.com/
    description: Public API Server
security:
  - Public: []
tags:
  - name: Authentication
    description: Obtain an OAuth 2.0 access token for the Alvys Public API.
  - name: Carrier Settlement Statements
    description: >-
      Search carrier settlement statements and retrieve a single statement by
      number.
  - name: Carriers
    description: Read carrier records, search carriers, and manage carrier documents.
  - name: Customers
    description: Create, read, update, delete, and search customer records.
  - name: Deductions
    description: >-
      Create one-time deductions and search or delete existing deduction
      records.
  - name: DispatchPreferences
    description: Dispatch preferences endpoints for reading dispatch rules and preferences.
  - name: Driver Settlement Statements
    description: >-
      Search driver settlement statements and retrieve a single statement by
      number.
  - name: Drivers
    description: >-
      Read driver records, search drivers and driver events, and manage driver
      documents.
  - name: Fuel
    description: Read and search fuel transactions.
  - name: Invoices
    description: >-
      Read invoices, create carrier invoices, and record carrier and customer
      payments.
  - name: Loads
    description: Read, update, search loads, and manage load documents and notes.
  - name: Locations
    description: Read and search company location details.
  - name: Maintenance
    description: Read and search maintenance records.
  - name: Tenders
    description: Create, accept, reject, cancel, update, and search inbound EDI tenders.
  - name: Tolls
    description: Read and search toll transactions.
  - name: Trailers
    description: Read trailers, search trailer events, and manage trailer documents.
  - name: Trips
    description: >-
      Read, search trips, manage trip documents, and record stop appointments,
      arrivals, and departures.
  - name: Trucks
    description: Read trucks, search truck events, and manage truck documents.
  - name: Users
    description: List and search users.
  - name: Visibility
    description: >-
      Read inbound and outbound visibility history and search outbound
      visibility errors.
  - name: Webhooks
    description: >-
      Create, read, update, delete, enable, disable, verify, test, and rotate
      secrets for webhook subscriptions; read event types, delivery logs, and
      health metrics.
paths:
  /api/p/v{version}/maintenance/search:
    post:
      tags:
        - Maintenance
      summary: Search maintenance records
      parameters:
        - name: version
          in: path
          description: API version (e.g., 1.0)
          required: true
          schema:
            type: string
            default: '1.0'
            example: '1.0'
      requestBody:
        content:
          application/json-patch+json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceSearchRequest
          application/json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceSearchRequest
          text/json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceSearchRequest
          application/*+json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceSearchRequest
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Alvys.Helpers.PagedResponse1Alvys.Models.Loads.MaintenanceResponse
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Microsoft.AspNetCore.Mvc.ValidationProblemDetails
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '429':
          description: Too Many Requests
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
      security:
        - Public: []
components:
  schemas:
    Alvys.Models.Maintenance.MaintenanceSearchRequest:
      required:
        - Page
        - PageSize
      type: object
      properties:
        Page:
          type: integer
          format: int32
        PageSize:
          type: integer
          format: int32
        TruckIds:
          type: array
          items:
            type: string
          nullable: true
        TrailerIds:
          type: array
          items:
            type: string
          nullable: true
        Categories:
          type: array
          items:
            type: string
          nullable: true
        Status:
          type: string
          nullable: true
        DateRange:
          allOf:
            - $ref: '#/components/schemas/Alvys.Models.Period'
          nullable: true
      additionalProperties: false
    Alvys.Helpers.PagedResponse1Alvys.Models.Loads.MaintenanceResponse:
      required:
        - Items
        - Page
        - PageSize
        - Total
      type: object
      properties:
        Page:
          type: integer
          format: int32
        PageSize:
          type: integer
          format: int32
        Facets:
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/Alvys.Helpers.ResultSetFacetItem'
          nullable: true
        Total:
          type: integer
          format: int64
        Items:
          type: array
          items:
            $ref: '#/components/schemas/Alvys.Models.Loads.MaintenanceResponse'
      additionalProperties: false
    Microsoft.AspNetCore.Mvc.ValidationProblemDetails:
      required:
        - Errors
      type: object
      properties:
        Errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
        Type:
          type: string
          nullable: true
        Title:
          type: string
          nullable: true
        Status:
          type: integer
          format: int32
          nullable: true
        Detail:
          type: string
          nullable: true
        Instance:
          type: string
          nullable: true
      additionalProperties: {}
    Microsoft.AspNetCore.Mvc.ProblemDetails:
      type: object
      properties:
        Type:
          type: string
          nullable: true
        Title:
          type: string
          nullable: true
        Status:
          type: integer
          format: int32
          nullable: true
        Detail:
          type: string
          nullable: true
        Instance:
          type: string
          nullable: true
      additionalProperties: {}
    Alvys.Models.Period:
      required:
        - Start
      type: object
      properties:
        Start:
          type: string
          format: date-time
        End:
          type: string
          format: date-time
          nullable: true
      additionalProperties: false
    Alvys.Helpers.ResultSetFacetItem:
      required:
        - Count
        - Value
      type: object
      properties:
        Value:
          type: string
        Count:
          type: integer
          format: int64
      additionalProperties: false
    Alvys.Models.Loads.MaintenanceResponse:
      required:
        - Amount
        - Category
        - CreatedAt
        - CreatedBy
        - Id
        - RelatedAsset
      type: object
      properties:
        Id:
          type: string
        PO:
          type: string
          nullable: true
        Reference:
          type: string
          nullable: true
        RelatedAsset:
          allOf:
            - $ref: '#/components/schemas/Alvys.Models.Loads.MaintenanceResponseAsset'
        Category:
          allOf:
            - $ref: >-
                #/components/schemas/Alvys.Models.Loads.MaintenanceResponseMaintenanceCategory
        Description:
          type: string
          nullable: true
        Comments:
          type: string
          nullable: true
        Amount:
          allOf:
            - $ref: '#/components/schemas/Alvys.Money'
        RepairShop:
          allOf:
            - $ref: '#/components/schemas/Alvys.Models.Loads.MaintenanceResponseShop'
          nullable: true
        Reminders:
          type: array
          items:
            $ref: '#/components/schemas/Alvys.Models.Maintenance.Asset.Reminder'
          nullable: true
        CreatedAt:
          type: string
          format: date-time
        CreatedBy:
          type: string
        ModifiedAt:
          type: string
          format: date-time
          nullable: true
        ModifiedBy:
          type: string
          nullable: true
      additionalProperties: false
    Alvys.Models.Loads.MaintenanceResponseAsset:
      required:
        - AssetId
        - AssetType
      type: object
      properties:
        AssetId:
          type: string
        AssetNumber:
          type: string
          nullable: true
        AssetType:
          type: string
      additionalProperties: false
    Alvys.Models.Loads.MaintenanceResponseMaintenanceCategory:
      required:
        - Id
        - Name
      type: object
      properties:
        Id:
          type: string
        Name:
          type: string
      additionalProperties: false
    Alvys.Money:
      required:
        - Amount
      type: object
      properties:
        Amount:
          type: number
          format: double
        Currency:
          type: integer
          format: int32
          nullable: true
      additionalProperties: false
    Alvys.Models.Loads.MaintenanceResponseShop:
      required:
        - Id
        - Name
      type: object
      properties:
        Id:
          type: string
        Name:
          type: string
      additionalProperties: false
    Alvys.Models.Maintenance.Asset.Reminder:
      type: object
      properties:
        id:
          type: string
          nullable: true
        DueDate:
          type: string
          format: date-time
          nullable: true
      additionalProperties: false
  securitySchemes:
    Public:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        OAuth 2.0 client-credentials access token. Obtain one from
        https://auth.alvys.com/oauth/token (grant_type=client_credentials,
        audience=https://api.alvys.com/public/), then paste it here. The
        playground sends it as `Authorization: Bearer <token>`.

````