Endpoint
Authentication
Bearer token for authentication. Format:
Bearer <access_token>Description
This endpoint synchronizes vehicles from theareas_placas table by:
- Retrieving all license plates with status
ACTIVADA(activated) - Checking which plates already have corresponding vehicle records
- Creating new vehicle records for plates that don’t exist in the
vehiculotable - Returning a summary of the sync operation
placa_id in the vehiculo table, preventing duplicate vehicle records for the same license plate.
Request Body
This endpoint does not require a request body.Response
Returns a summary object with sync statistics.Success message indicating the sync operation completed
Total number of active license plates found in the system
Number of new vehicle records created during this sync operation
Number of plates that already had corresponding vehicle records before the sync
Response Example
Successful Sync
No Active Plates
When there are no active plates to sync:Examples
Perform vehicle sync
Error Responses
401 Unauthorized
500 Internal Server Error
Sync Process Details
Step 1: Retrieve Active Plates
The endpoint queries theareas_placas table for all plates with estado = 'ACTIVADA':
Step 2: Check Existing Vehicles
Retrieves all existing vehicle records to identify which plates already have vehicles:Step 3: Filter and Insert
Filters out plates that already have vehicle records and inserts new records for the remaining plates:Step 4: Return Summary
Provides a summary showing:- How many active plates exist in total
- How many new vehicles were created
- How many already existed
Use Cases
Initial Fleet Setup
When first setting up the fleet management system, sync all active plates to create vehicle records:Regular Maintenance
Run periodically to ensure new activated plates get vehicle records:Notes
- The sync operation is idempotent - running it multiple times will not create duplicate records
- Only plates with status
ACTIVADAare considered for sync - The unique constraint
vehiculo_placa_id_keyon theplaca_idcolumn prevents duplicate vehicle records - Newly created vehicle records will have
empresa_idandoperacion_idasnullinitially - After syncing, you should update vehicle records with company and operation information using the update endpoint (if available)
- The operation uses a Set data structure to efficiently filter out existing plates before insertion