Get Configuration
GET /api/configuration
Retrieve the current application configuration, including the active collection center.
Response
The ID of the currently active collection center, or
null if not configuredUpdate Configuration
PUT /api/configuration
Update the application configuration. This endpoint sets the active collection center and automatically assigns unassigned data to the center if it’s the only center in the system.
Request Body
The ID of the collection center to set as active. Pass
null to clear the active center.Automatic Data Assignment
When setting an active collection center, if there is exactly one collection center in the system, the API automatically assigns any unassigned data to that center:- Generators with
collection_center_id IS NULL→ assigned to the active center - Vehicles with
collection_center_id IS NULL→ assigned to the active center - Tickets with
collection_center_id IS NULL→ assigned to the active center
Response
The ID of the newly active collection center
Transaction Logic
The configuration update uses a database transaction to ensure atomicity:- Begin transaction
- Insert or update the app_configuration record (single-row table with id=1)
- If the active center is set and there’s only one center in the system:
- Assign all unassigned generators to the center
- Assign all unassigned vehicles to the center
- Assign all unassigned tickets to the center
- Commit transaction
Error Responses
| Status | Description |
|---|---|
| 500 | Database error during retrieval or update |
Related
Collection Centers API
Manage collection centers
Dashboard
View and change the active center in the UI