> ## 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.

# Create maintenance record

> Open a maintenance record against a truck or trailer, with category, repair shop, vendor, cost, odometer and reminders, safely retryable with ExternalId.

The Create Maintenance Record endpoint opens a **maintenance record** against one of your trucks or trailers, for example a PM service or a repair invoice from your shop system. On success it returns the new record and its optimistic-concurrency token in the `ETag` response header. Send that value in the `If-Match` header of a later [Update maintenance record](https://docs.alvys.com/en/api/reference/maintenance/update-maintenance-record.md) request. For more information on how versioning works and how to include it in your requests, please refer to the [Versioning](https://docs.alvys.com/en/api/guides/versioning.md) page.

> [!NOTE]
>
> This endpoint requires the `maintenance:create` scope. See [Authentication](https://docs.alvys.com/en/api/guides/authentication-1.md).

To attach the invoice or another file to the record, use [Upload maintenance document](https://docs.alvys.com/en/api/reference/maintenance/upload-maintenance-document.md) with the `Id` this endpoint returns.

### Asset

`Asset.AssetId` is the Alvys id of the truck or trailer, as returned by [Search trucks](https://docs.alvys.com/en/api/reference/trucks/search-trucks.md) or [Search trailers](https://docs.alvys.com/en/api/reference/trailers/search-trailers.md). `Asset.AssetType` is `Truck` or `Trailer` (case-insensitive). The asset cannot be changed after the record is created.

If the asset does not exist in your account, or it belongs to a subsidiary your credential cannot access, the request is rejected with `404 Not Found`.

### Category, repair shop and vendor

`Category`, `RepairShop` and `Vendor` are resolved by `Name`. A name that already exists in your maintenance lists is reused. A name that does not exist yet is added, the same way typing a new value in the Alvys maintenance form adds it. The response returns the `Id` and `Name` the value was saved under.

You may send back the `Id` you received in a response, but it is not used to look anything up: always send `Name` with it. An `Id` without a `Name` is rejected with `400 Bad Request`.

### Retry safely with ExternalId

`ExternalId` is your own unique id for the record, such as your work order or invoice number. Send the same value when you retry a request, for example after a timeout. If a record with that `ExternalId` already exists, it is returned with `200 OK` and no second record is created. Without `ExternalId`, a retry creates another record.

* Matching ignores case and surrounding spaces.
* The check protects a retry that follows the first request. Two requests with the same `ExternalId` sent at exactly the same time can both create a record.
* If the existing record with that `ExternalId` belongs to an asset your credential cannot access, the request is rejected with `404 Not Found`.

### Driver deductions

A record created through this endpoint is never linked to a driver settlement deduction, so creating one does not change any driver's pay. `IsDeducted` is `false` on the response. A deduction can still be linked to the record later in Alvys.

***

### Request parameters

The following parameter is required in the URL path:

| Parameter | Type | Required | Description |
| - | - | - | - |
| version | String | Yes | The version of the API. |

***

### Request body

Only `Asset` and `Category` are required.

| Field | Type | Required | Description |
| - | - | - | - |
| Asset | Object | Yes | The truck or trailer the record belongs to. See [Asset](#asset). |
| Asset.AssetId | String | Yes | The Alvys id of the truck or trailer. |
| Asset.AssetType | String | Yes | `Truck` or `Trailer` (case-insensitive). |
| Category | Object | Yes | The kind of work, for example `PM Service`. See [Category, repair shop and vendor](#category-repair-shop-and-vendor). |
| Category.Name | String | Yes | The category name. Up to 200 characters. |
| Category.Id | String | No | The category id from a previous response. Not used to look anything up. |
| Status | String | No | One of `Urgent`, `Open`, `Closed` (case-insensitive). Defaults to `Open`. |
| Date | String (Date-Time) | No | When the work was done or is scheduled. |
| Description | String | No | A short summary of the work. Up to 500 characters. |
| Comments | String | No | Free-form notes. Up to 2,000 characters. |
| Amount | Number | No | The total cost in USD. Cannot be negative. Defaults to `0`. |
| PO | String | No | The purchase order number. Up to 100 characters. |
| Reference | String | No | Your reference number, for example an invoice or work order number. Up to 100 characters. |
| RepairShop | Object | No | Where the work is done, with `Name` (up to 200 characters) and an optional `Id`, as in `Category`. |
| Vendor | Object | No | Who bills for the work, with `Name` (up to 200 characters) and an optional `Id`, as in `Category`. |
| OdometerReading | Number | No | The odometer of the asset at the time of service, in miles. Cannot be negative. Defaults to `0`. |
| WorkPerformed | String | No | A longer description of the work done. Up to 2,000 characters. |
| Reminders | Array | No | Follow-up dates shown on the record. Up to 25. |
| Reminders.DueDate | String (Date-Time) | Yes | When the reminder is due. |
| ExternalId | String | No | Your own unique id for the record, used to make retries safe. Up to 100 characters. See [Retry safely with ExternalId](#retry-safely-with-externalid). |

***

### Example cURL request

```bash theme={null}
curl --location 'https://integrations.alvys.com/api/p/v1/maintenance' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
  "Asset": { "AssetId": "TR1000000000000417", "AssetType": "Truck" },
  "Category": { "Name": "PM Service" },
  "Status": "Closed",
  "Date": "2026-11-24T14:00:00Z",
  "Description": "A-service and oil change",
  "Amount": 412.75,
  "PO": "PO-88213",
  "Reference": "WO-55120",
  "RepairShop": { "Name": "Rocket Repairs" },
  "Vendor": { "Name": "Rocket Repairs" },
  "OdometerReading": 412880,
  "WorkPerformed": "Changed engine oil and filters, greased chassis, inspected brakes.",
  "Reminders": [{ "DueDate": "2027-02-24T00:00:00Z" }],
  "ExternalId": "WO-55120"
}'
```

Replace `YOUR_ACCESS_TOKEN` with your actual Bearer token.

***

### Response fields

A successful request returns the maintenance record. The record's current `ETag` is in the `ETag` response header.

| Field | Type | Description |
| - | - | - |
| Id | String | The unique identifier of the maintenance record. |
| RecordNumber | String | The record number Alvys assigned. Unique within your account. |
| ExternalId | String | The `ExternalId` you sent, if any. |
| Status | String | `Urgent`, `Open` or `Closed`. |
| Date | String (Date-Time) | When the work was done or is scheduled. |
| RelatedAsset | Object | The truck or trailer, with `AssetId`, `AssetNumber` and `AssetType`. |
| Category | Object | The category, with `Id` and `Name`. |
| RepairShop | Object | The repair shop, with `Id` and `Name`. |
| Vendor | Object | The vendor, with `Id` and `Name`. |
| Description | String | The short summary of the work. |
| Comments | String | Free-form notes. |
| WorkPerformed | String | The longer description of the work done. |
| Amount | Object | The total cost, with `Amount` and `Currency`. |
| PO | String | The purchase order number. |
| Reference | String | Your reference number. |
| OdometerReading | Number | The odometer reading in miles. |
| Reminders | Array | The reminders, each with `id` and `DueDate`. |
| IsDeducted | Boolean | Whether the record is linked to a driver settlement deduction. Always `false` on a new record. |
| CreatedAt | String (Date-Time) | When the record was created. |
| CreatedBy | String | Who created the record. |
| ModifiedAt | String (Date-Time) | When the record was last changed. |
| ModifiedBy | String | Who last changed the record. |

***

### Example response

**201 Created**

```json theme={null}
{
  "Id": "4b0e6a52-0000-0000-0000-000000000417",
  "RecordNumber": "1042",
  "ExternalId": "WO-55120",
  "Status": "Closed",
  "Date": "2026-11-24T14:00:00+00:00",
  "RelatedAsset": { "AssetId": "TR1000000000000417", "AssetNumber": "T-417", "AssetType": "Truck" },
  "Category": { "Id": "118", "Name": "PM Service" },
  "RepairShop": { "Id": "204", "Name": "Rocket Repairs" },
  "Vendor": { "Id": "311", "Name": "Rocket Repairs" },
  "Description": "A-service and oil change",
  "WorkPerformed": "Changed engine oil and filters, greased chassis, inspected brakes.",
  "Amount": { "Amount": 412.75 },
  "PO": "PO-88213",
  "Reference": "WO-55120",
  "OdometerReading": 412880,
  "Reminders": [{ "id": "9f4d2c1a-0000-0000-0000-000000000001", "DueDate": "2027-02-24T00:00:00+00:00" }],
  "IsDeducted": false,
  "CreatedAt": "2026-11-30T15:04:05.000Z"
}
```

The example shows a subset of the response fields.

***

### Status codes

| Status | Meaning |
| - | - |
| 201 | The record was created. |
| 200 | A record with this `ExternalId` already existed. It is returned and nothing new was created. |
| 400 | The request body failed validation. The response lists the invalid fields. |
| 401 | The request was not authenticated. |
| 403 | The caller lacks the `maintenance:create` scope. |
| 404 | The asset does not exist in your account or is outside the subsidiaries your credential can access. |
| 409 | The record clashed with one saved at the same moment and was not created. Retry the request, with an `ExternalId` so a retry is safe. |
| 429 | The rate limit was exceeded. |

***

### 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](https://docs.alvys.com/en/api/guides/rate-limits.md) 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.


## OpenAPI

````yaml POST /api/p/v{version}/maintenance
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, and search loads; manage load documents, notes, and custom
      references.
  - name: Locations
    description: Read and search company location details.
  - name: Maintenance
    description: Read and search maintenance records.
  - name: References
    description: >-
      List tenant custom reference definitions and create or update values on
      existing loads, stops, and trips.
  - name: Subsidiaries
    description: >-
      List your company's subsidiaries and read a single subsidiary, so an
      integration can resolve a subsidiary id to a recognizable name.
  - name: Tenders
    description: Create, accept, reject, cancel, update, and search inbound EDI tenders.
  - name: Tolls
    description: Read and search toll transactions.
  - name: Tracking
    description: >-
      Record an asset's current location or telemetry from a third-party source,
      such as an external ELD or a self-reporting vehicle.
  - name: Trailers
    description: Read trailers, search trailer events, and manage trailer documents.
  - name: Trips
    description: >-
      Read and search trips; manage trip documents, stop appointments, arrivals,
      departures, and stop and trip custom references.
  - 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.
  - name: Accessorials
  - name: Credits
paths:
  /api/p/v{version}/maintenance:
    post:
      tags:
        - Maintenance
      summary: Create maintenance record
      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.MaintenanceCreateRequest
          application/json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceCreateRequest
          text/json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceCreateRequest
          application/*+json:
            schema:
              allOf:
                - $ref: >-
                    #/components/schemas/Alvys.Models.Maintenance.MaintenanceCreateRequest
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Alvys.Models.Loads.MaintenanceResponse'
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Alvys.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'
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '404':
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
            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'
            application/json:
              schema:
                $ref: '#/components/schemas/Microsoft.AspNetCore.Mvc.ProblemDetails'
      security:
        - Public: []
components:
  schemas:
    Alvys.Models.Maintenance.MaintenanceCreateRequest:
      required:
        - Asset
        - Category
      type: object
      properties:
        Asset:
          allOf:
            - $ref: >-
                #/components/schemas/Alvys.Models.Maintenance.MaintenanceAssetRequest
        Category:
          allOf:
            - $ref: >-
                #/components/schemas/Alvys.Models.Maintenance.MaintenanceReferenceRequest
        Status:
          type: string
          nullable: true
        Date:
          type: string
          format: date-time
          nullable: true
        Description:
          type: string
          nullable: true
        Comments:
          type: string
          nullable: true
        Amount:
          type: number
          format: double
          nullable: true
        PO:
          type: string
          nullable: true
        Reference:
          type: string
          nullable: true
        RepairShop:
          allOf:
            - $ref: >-
                #/components/schemas/Alvys.Models.Maintenance.MaintenanceReferenceRequest
          nullable: true
        Vendor:
          allOf:
            - $ref: >-
                #/components/schemas/Alvys.Models.Maintenance.MaintenanceReferenceRequest
          nullable: true
        OdometerReading:
          type: number
          format: double
          nullable: true
        WorkPerformed:
          type: string
          nullable: true
        Reminders:
          type: array
          items:
            $ref: >-
              #/components/schemas/Alvys.Models.Maintenance.MaintenanceReminderRequest
          nullable: true
        ExternalId:
          type: string
          nullable: true
      additionalProperties: false
    Alvys.Models.Loads.MaintenanceResponse:
      required:
        - Amount
        - Category
        - CreatedAt
        - CreatedBy
        - Id
        - RelatedAsset
        - Status
        - OdometerReading
        - IsDeducted
      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
        RecordNumber:
          type: string
          description: >-
            Per-tenant sequence number, server-assigned and not writable. Unique
            within your tenant, so it is safe to reconcile against: a
            simultaneous create cannot take the same number. NOT guaranteed
            gapless or strictly increasing - a losing race burns a number and a
            deleted record leaves its number behind, so treat it as an
            identifier, not a count.
          nullable: true
        Status:
          type: string
        Date:
          type: string
          format: date-time
          nullable: true
        OdometerReading:
          type: number
          format: double
        WorkPerformed:
          type: string
          nullable: true
        Vendor:
          allOf:
            - $ref: '#/components/schemas/Alvys.Models.Loads.MaintenanceResponseShop'
          nullable: true
        IsDeducted:
          type: boolean
          description: >-
            True when this record is linked to a driver settlement deduction.
            While true, a PATCH that changes Category, Description, Amount or
            Date is refused with 422, because applying it would replace the
            driver's linked deduction. All other fields stay writable.
        ExternalId:
          type: string
          nullable: true
      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.Maintenance.MaintenanceAssetRequest:
      required:
        - AssetId
        - AssetType
      type: object
      properties:
        AssetId:
          type: string
        AssetType:
          type: string
      additionalProperties: false
    Alvys.Models.Maintenance.MaintenanceReferenceRequest:
      type: object
      properties:
        Id:
          type: string
          nullable: true
        Name:
          type: string
          nullable: true
      additionalProperties: false
    Alvys.Models.Maintenance.MaintenanceReminderRequest:
      required:
        - DueDate
      type: object
      properties:
        DueDate:
          type: string
          format: date-time
      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>`.

````