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

# Create vehicle

> Creates a new vehicle for the specified business. This endpoint is idempotent using the `external_id` field as the idempotency key.



## OpenAPI

````yaml post /v1/businesses/{businessId}/mileage/vehicles
openapi: 3.0.1
info:
  title: API
  version: latest
servers: []
security:
  - BearerAuth: []
tags: []
externalDocs:
  url: /
paths:
  /v1/businesses/{businessId}/mileage/vehicles:
    post:
      tags: []
      summary: Create vehicle
      description: >-
        Creates a new vehicle for the specified business. This endpoint is
        idempotent using the `external_id` field as the idempotency key.
      operationId: business.mileage.vehicles.post
      parameters:
        - name: businessId
          in: path
          description: The UUID of the business.
          required: true
          schema:
            type: string
            format: uuid
        - name: Content-Type
          in: header
          description: Content-Type must be set to application/json.
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateVehicleParams'
      responses:
        '200':
          description: Existing vehicle with matching external_id was updated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiVehicle'
        '201':
          description: Vehicle created successfully.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiVehicle'
        '400':
          description: Invalid request parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Business not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      deprecated: false
components:
  schemas:
    CreateVehicleParams:
      type: object
      properties:
        external_id:
          type: string
          nullable: true
          description: >-
            An optional external identifier for the vehicle. If provided and a
            vehicle with this external_id already exists, the existing vehicle
            will be updated instead of creating a new one.
        make_and_model:
          type: string
          description: The make and model of the vehicle (e.g., 'Toyota Camry').
        year:
          type: integer
          description: The model year of the vehicle.
        license_plate:
          type: string
          nullable: true
          description: The license plate number of the vehicle.
        vin:
          type: string
          nullable: true
          description: The Vehicle Identification Number (VIN).
        description:
          type: string
          nullable: true
          description: An optional description or notes about the vehicle.
        is_primary:
          type: boolean
          default: false
          description: >-
            Whether this should be the primary vehicle. If true, any existing
            primary vehicle will be demoted.
      required:
        - make_and_model
        - year
    ApiVehicle:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The unique identifier of the vehicle.
        business_id:
          type: string
          format: uuid
          description: The UUID of the business this vehicle belongs to.
        external_id:
          type: string
          nullable: true
          description: >-
            An optional external identifier for the vehicle, used for
            idempotency.
        make_and_model:
          type: string
          description: The make and model of the vehicle (e.g., 'Toyota Camry').
        year:
          type: integer
          description: The model year of the vehicle.
        license_plate:
          type: string
          nullable: true
          description: The license plate number of the vehicle.
        vin:
          type: string
          nullable: true
          description: The Vehicle Identification Number (VIN).
        description:
          type: string
          nullable: true
          description: An optional description or notes about the vehicle.
        is_primary:
          type: boolean
          description: >-
            Whether this is the primary vehicle for the business. Only one
            vehicle can be primary at a time.
        is_eligible_for_deletion:
          type: boolean
          description: >-
            Whether the vehicle can be deleted. A vehicle cannot be deleted if
            it has trips or is archived.
        created_at:
          type: string
          format: date-time
          description: Timestamp when the vehicle was created.
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the vehicle was last updated.
        archived_at:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when the vehicle was archived, or null if not archived.
        deleted_at:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when the vehicle was deleted, or null if not deleted.
      required:
        - id
        - business_id
        - make_and_model
        - year
        - is_primary
        - is_eligible_for_deletion
        - created_at
        - updated_at
    ApiError:
      type: object
      description: An error object returned in API error responses.
      properties:
        type:
          $ref: '#/components/schemas/ApiErrorType'
          description: >-
            A fixed category for the error, helpful for categorizing and
            processing errors.
        description:
          type: string
          description: A human-readable error description.
        error_enum:
          $ref: '#/components/schemas/ApiEnumErrorType'
          description: >-
            A stable, machine-readable identifier for programmatically handling
            specific error conditions. Only present for 4xx client errors—not
            included for 5xx server errors. Use this instead of parsing the
            description field, as enum values remain stable across API versions.
          nullable: true
        meta:
          type: object
          description: Optional additional information about the error.
          nullable: true
      required:
        - type
        - description
    ApiErrorType:
      type: string
      enum:
        - ResourceArchived
        - AuthFailure
        - Plaid
        - Stripe
        - InvalidState
        - ResourceNotFound
        - InvalidParameters
        - JsonSerialization
        - Unknown
        - BadRequest
        - PaginationCursor
        - Conflict
        - LedgerOperationFailed
    ApiEnumErrorType:
      type: string
      description: >-
        Stable enum values for programmatic error handling. Only present in 4xx
        error responses.
      enum:
        - AccessCodeInvalid
        - BalanceSheetDoesNotBalance
        - BalanceSheetMissingAccount
        - BankStatementParserError
        - BillStateError
        - BulkCategorizeFailure
        - BulkMatchFailure
        - BusinessTaskAlreadyCompleted
        - BusinessTaskDeleted
        - CalendlyOAuthError
        - CallBookingError
        - CantUpdateTransactionInCustomerPayout
        - CantUpdateTransactionInVendorPayout
        - CheckPayrollConfigNotFound
        - CheckPayrollServiceNotFound
        - ClerkUserAlreadyExists
        - ConflictingQueryParams
        - CustomAccountAlreadyExists
        - CustomTransactionCsvParsingError
        - CustomTransactionUploadFailure
        - CustomerPayoutInputFormatError
        - DoesNotMatchExistingEntity
        - EmptyBatchRequest
        - ExpenseParserError
        - ExternalAccountBalanceReconciliationError
        - ExternalIdConflict
        - InvalidCategory
        - InvalidEffectiveDate
        - InvalidLedgerOperation
        - InvalidMonthlyAverageRange
        - InvalidMultiPartRequest
        - InvalidPaginationCursor
        - InvalidPayload
        - InvoiceDeleted
        - InvoiceNotFound
        - InvoiceReferenceMismatch
        - InvoiceStateError
        - ManualRateLimit
        - MultipleTagKeyFiltersUnsupported
        - NoCognitoUserFound
        - NoOpeningBalanceFound
        - NotYetReconciled
        - OnePasswordApiError
        - OnePasswordItemNotFound
        - OnePasswordVaultNotFound
        - OpenAICategorizationError
        - PaymentLinkInvalid
        - PayrollStateError
        - PeriodIsClosed
        - PeriodNotClosed
        - PhoneNumberAlreadyRegistered
        - PlaidApiError
        - PlaidConnectionBroken
        - PlaidCreateLinkTokenError
        - PlaidCredentialsNotConfigured
        - PlaidExchangePublicTokenError
        - PlaidGetInstitutionByIdError
        - PlaidGetItemError
        - PlaidInvalidEnvironment
        - PlaidItemAlreadyExists
        - PlaidItemNotFound
        - PlaidProcessorApiError
        - PlaidUnlinkItemError
        - QueryParamFormat
        - QueryParamMissing
        - QuickbooksBrokenConnection
        - QuickbooksConnectionAlreadyExists
        - QuickbooksConnectionAlreadySyncing
        - QuickbooksConnectionMissing
        - QuickbooksConnectionNotActivated
        - QuickbooksInvalidRequest
        - QuickbooksInvalidState
        - QuickbooksNoMatchingAccount
        - QuickbooksNonPostingAccountType
        - QuickbooksNotConfigured
        - QuickbooksOAuthCallbackInvalid
        - QuickbooksOAuthError
        - QuickbooksTokenExpired
        - ResourceArchived
        - ScheduleCNotConfigured
        - SmsNotEnabled
        - SpecifiedBadRequest
        - SpecifiedIdNotFound
        - SplitTransactionError
        - StepEvaluationBadRequest
        - StripeConnectAccountIdNotFound
        - StripeCredentialsNotConfigured
        - StripeGetBalanceForConnectAccountFailure
        - StripeRedirectOrRefreshUrlNotConfigured
        - TagFilterNotFound
        - UnexpectedQueryParam
        - UnitAccountsInUse
        - WrongAnswerType
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````