Vehicle Endpoints

Vehicle Endpoints

This guide covers the vehicle endpoints in the AutoElite API, which allow you to retrieve, create, update, and delete vehicle listings.

Base URL

All vehicle endpoints are accessible at:

https://api.autoelite.io/api/vehicles

Authentication

All requests to the vehicle endpoints require authentication using an API key. Include your API key in the X-API-Key header:

X-API-Key: your-api-key-here

Endpoints

Get All Vehicles

GET /api/vehicles

Retrieve a list of vehicles, optionally filtered by various parameters.

Query Parameters

Parameter Type Description
dealer_id integer Filter vehicles by dealer ID
status string Filter by status (available, sold, pending)
featured boolean Filter by featured status (true, false)
make string Filter by vehicle make
model string Filter by vehicle model
year integer Filter by vehicle year
min_price integer Filter by minimum price
max_price integer Filter by maximum price
limit integer Maximum number of results to return
offset integer Number of results to skip (for pagination)

Example Request

curl -X GET "https://api.autoelite.io/api/vehicles?dealer_id=1&status=available" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "meta": {
    "total": 4,
    "filter_applied": true,
    "dealer_id": 1,
    "timestamp": "2025-12-03T19:52:19.148Z",
    "sql": "SELECT * FROM vehicles WHERE 1=1 AND dealer_id = ? AND status = ? ORDER BY created_at DESC"
  },
  "vehicles": [
    {
      "id": 32,
      "dealer_id": 1,
      "make": "Tesla",
      "model": "Model Y",
      "year": 2025,
      "trim": null,
      "price": 45000,
      "mileage": null,
      "exterior_color": null,
      "interior_color": null,
      "vin": null,
      "stock_number": null,
      "description": null,
      "features": null,
      "status": "available",
      "featured": 0,
      "created_at": "2025-11-28 05:30:15",
      "updated_at": "2025-11-28 05:30:15",
      "title": null
    },
    {
      "id": 31,
      "dealer_id": 1,
      "make": "Test Make",
      "model": "Test Model",
      "year": 2023,
      "price": 10000,
      "status": "available",
      "created_at": "2025-11-27 23:29:30",
      "updated_at": "2025-11-27 23:29:30",
      "title": "Test Vehicle via API"
    }
  ]
}

Get a Specific Vehicle

GET /api/vehicles/:id

Retrieve a specific vehicle by its ID.

Example Request

curl -X GET "https://api.autoelite.io/api/vehicles/32" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "id": 32,
  "dealer_id": 1,
  "make": "Tesla",
  "model": "Model Y",
  "year": 2025,
  "trim": null,
  "price": 45000,
  "mileage": null,
  "exterior_color": null,
  "interior_color": null,
  "vin": null,
  "stock_number": null,
  "description": null,
  "features": null,
  "status": "available",
  "featured": 0,
  "fuel_type": "Electric",
  "transmission": "Automatic",
  "engine": "",
  "drivetrain": "AWD",
  "body_style": "SUV",
  "condition": "New",
  "seats": 5,
  "created_at": "2025-11-28 05:30:15",
  "updated_at": "2025-11-28 05:30:15",
  "title": "2025 Tesla Model Y"
}

Create a Vehicle

POST /api/vehicles

Create a new vehicle listing.

Request Body

Field Type Required Description
make string Yes Vehicle make
model string Yes Vehicle model
year integer Yes Vehicle year
price number Yes Vehicle price
dealer_id integer Yes* Dealer ID (*Not required if using dealer-specific API key)
title string No Vehicle title (auto-generated if not provided)
trim string No Vehicle trim level
mileage integer No Vehicle mileage
exterior_color string No Exterior color
interior_color string No Interior color
vin string No Vehicle identification number
stock_number string No Dealer stock number
description string No Vehicle description
features string No Vehicle features (comma-separated)
status string No Vehicle status (default: available)
featured boolean No Whether the vehicle is featured (default: false)
fuel_type string No Fuel type
transmission string No Transmission type
engine string No Engine details
drivetrain string No Drivetrain type
body_style string No Body style
condition string No Vehicle condition
seats integer No Number of seats

Example Request

curl -X POST "https://api.autoelite.io/api/vehicles" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "make": "Toyota",
    "model": "Camry",
    "year": 2023,
    "price": 25000,
    "dealer_id": 1,
    "mileage": 5000,
    "exterior_color": "Blue",
    "interior_color": "Black",
    "vin": "1HGBH41JXMN109186",
    "status": "available"
  }'

Example Response

{
  "id": 33,
  "dealer_id": 1,
  "make": "Toyota",
  "model": "Camry",
  "year": 2023,
  "price": 25000,
  "mileage": 5000,
  "exterior_color": "Blue",
  "interior_color": "Black",
  "vin": "1HGBH41JXMN109186",
  "status": "available",
  "created_at": "2025-12-03T21:30:00.000Z",
  "updated_at": "2025-12-03T21:30:00.000Z",
  "title": "2023 Toyota Camry"
}

Update a Vehicle

PUT /api/vehicles/:id

Update an existing vehicle listing.

Example Request

curl -X PUT "https://api.autoelite.io/api/vehicles/33" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "price": 24500,
    "status": "pending",
    "description": "Well-maintained sedan with low mileage"
  }'

Example Response

{
  "id": 33,
  "dealer_id": 1,
  "make": "Toyota",
  "model": "Camry",
  "year": 2023,
  "price": 24500,
  "mileage": 5000,
  "exterior_color": "Blue",
  "interior_color": "Black",
  "vin": "1HGBH41JXMN109186",
  "status": "pending",
  "description": "Well-maintained sedan with low mileage",
  "created_at": "2025-12-03T21:30:00.000Z",
  "updated_at": "2025-12-03T21:35:00.000Z",
  "title": "2023 Toyota Camry"
}

Delete a Vehicle

DELETE /api/vehicles/:id

Delete a vehicle listing.

Example Request

curl -X DELETE "https://api.autoelite.io/api/vehicles/33" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

{
  "success": true,
  "message": "Vehicle deleted successfully"
}

Vehicle Images

Get Vehicle Images

GET /api/vehicles/:id/images

Retrieve images for a specific vehicle.

Example Request

curl -X GET "https://api.autoelite.io/api/vehicles/32/images" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json"

Example Response

[
  {
    "id": 1,
    "vehicle_id": 32,
    "image_url": "https://storage.autoelite.io/vehicles/32/image1.jpg",
    "is_primary": true,
    "display_order": 0,
    "created_at": "2025-11-28T05:35:00.000Z"
  },
  {
    "id": 2,
    "vehicle_id": 32,
    "image_url": "https://storage.autoelite.io/vehicles/32/image2.jpg",
    "is_primary": false,
    "display_order": 1,
    "created_at": "2025-11-28T05:35:00.000Z"
  }
]

Add Vehicle Image

POST /api/vehicles/:id/images

Add an image to a vehicle listing.

Example Request

curl -X POST "https://api.autoelite.io/api/vehicles/32/images" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://storage.autoelite.io/vehicles/32/image3.jpg",
    "is_primary": false,
    "display_order": 2
  }'

Example Response

{
  "id": 3,
  "vehicle_id": 32,
  "image_url": "https://storage.autoelite.io/vehicles/32/image3.jpg",
  "is_primary": false,
  "display_order": 2,
  "created_at": "2025-12-03T21:40:00.000Z"
}

Error Handling

The API uses standard HTTP status codes to indicate success or failure:

  • 200 OK: Request succeeded
  • 201 Created: Resource created successfully
  • 400 Bad Request: Invalid request parameters
  • 401 Unauthorized: Missing or invalid API key
  • 403 Forbidden: Insufficient permissions or attempting to access another dealer's data
  • 404 Not Found: Vehicle not found
  • 500 Internal Server Error: Server error

Error responses include a JSON body with an error message:

{
  "error": "Vehicle not found",
  "timestamp": "2025-12-03T21:45:00.000Z"
}

Dealer-Specific Access

If you're using an API key associated with a specific dealer:

  1. The API automatically filters results to only show vehicles belonging to that dealer
  2. Attempts to access vehicles from other dealers will be rejected with a 403 Forbidden error
  3. New vehicles will automatically be assigned to the associated dealer, even if you specify a different dealer_id
  4. Updates to vehicles will be restricted to those belonging to the associated dealer

For more information, see the Dealer-Specific Access Control guide.

Code Examples

JavaScript

// Get all vehicles for a specific dealer
async function getVehicles(dealerId) {
  const response = await fetch(`https://api.autoelite.io/api/vehicles?dealer_id=${dealerId}`, {
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    }
  });
  
  const data = await response.json();
  return data.vehicles;
}

// Create a new vehicle
async function createVehicle(vehicleData) {
  const response = await fetch('https://api.autoelite.io/api/vehicles', {
    method: 'POST',
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(vehicleData)
  });
  
  return await response.json();
}

// Update a vehicle
async function updateVehicle(id, vehicleData) {
  const response = await fetch(`https://api.autoelite.io/api/vehicles/${id}`, {
    method: 'PUT',
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(vehicleData)
  });
  
  return await response.json();
}

// Delete a vehicle
async function deleteVehicle(id) {
  const response = await fetch(`https://api.autoelite.io/api/vehicles/${id}`, {
    method: 'DELETE',
    headers: {
      'X-API-Key': 'your-api-key-here',
      'Content-Type': 'application/json'
    }
  });
  
  return await response.json();
}

Python

import requests

API_KEY = "your-api-key-here"
BASE_URL = "https://api.autoelite.io"

# Get all vehicles for a specific dealer
def get_vehicles(dealer_id=None):
    url = f"{BASE_URL}/api/vehicles"
    params = {}
    if dealer_id:
        params["dealer_id"] = dealer_id
        
    response = requests.get(
        url,
        params=params,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    data = response.json()
    return data.get("vehicles", [])

# Create a new vehicle
def create_vehicle(vehicle_data):
    url = f"{BASE_URL}/api/vehicles"
    
    response = requests.post(
        url,
        json=vehicle_data,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

# Update a vehicle
def update_vehicle(id, vehicle_data):
    url = f"{BASE_URL}/api/vehicles/{id}"
    
    response = requests.put(
        url,
        json=vehicle_data,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

# Delete a vehicle
def delete_vehicle(id):
    url = f"{BASE_URL}/api/vehicles/{id}"
    
    response = requests.delete(
        url,
        headers={
            "X-API-Key": API_KEY,
            "Content-Type": "application/json"
        }
    )
    
    return response.json()

Next Steps