Skip to main content

List Generators

GET /api/generators Retrieve all generators, optionally filtered by collection center.

Query Parameters

collectionCenterId
string
Filter generators by collection center ID. If not provided, uses the active center from configuration.

Response

Returns an array of generator objects sorted by name.

Example Request

curl http://localhost:4000/api/generators?collectionCenterId=center-1

Example Response

[
  {
    "id": "gen-1",
    "name": "Restaurant El Sabor",
    "rif": "J-12345678-9",
    "phone": "+58 414 1234567",
    "address": "Av. Principal, Local 5",
    "sector": "Centro",
    "collection_mode": "Puerta a Puerta",
    "collection_center_id": "center-1",
    "created_at": "2026-01-15T10:00:00Z"
  },
  {
    "id": "gen-2",
    "name": "Taller Mecánico Los Tres",
    "rif": "J-98765432-1",
    "phone": "+58 424 9876543",
    "address": "Calle 5, Galpón 3",
    "sector": "Industrial",
    "collection_mode": "Centro de Acopio",
    "collection_center_id": "center-1",
    "created_at": "2026-02-01T14:30:00Z"
  }
]

Get Generator by ID

GET /api/generators/:id Retrieve a single generator by its ID.

Path Parameters

id
string
required
Generator ID

Response

Returns a single generator object or null if not found.

Example Request

curl http://localhost:4000/api/generators/gen-1

Example Response

{
  "id": "gen-1",
  "name": "Restaurant El Sabor",
  "rif": "J-12345678-9",
  "phone": "+58 414 1234567",
  "address": "Av. Principal, Local 5",
  "sector": "Centro",
  "collection_mode": "Puerta a Puerta",
  "collection_center_id": "center-1",
  "created_at": "2026-01-15T10:00:00Z"
}

Create Generator

POST /api/generators Create a new waste oil generator.

Request Body

id
string
required
Unique generator identifier (UUID)
name
string
required
Generator name (business name)
rif
string
required
Tax identification number (RIF)
phone
string
required
Contact phone number
address
string
required
Physical address
sector
string
required
Sector or neighborhood
collectionMode
string
Collection mode (optional)
collectionCenterId
string
Associated collection center ID (optional)

Response

Returns the created generator object with created_at timestamp.

Example Request

curl -X POST http://localhost:4000/api/generators \
  -H "Content-Type: application/json" \
  -d '{
    "id": "gen-new-1",
    "name": "Panadería La Espiga",
    "rif": "J-55555555-5",
    "phone": "+58 412 5555555",
    "address": "Calle 10, Edificio A",
    "sector": "Norte",
    "collectionMode": "Puerta a Puerta",
    "collectionCenterId": "center-1"
  }'

Example Response

{
  "id": "gen-new-1",
  "name": "Panadería La Espiga",
  "rif": "J-55555555-5",
  "phone": "+58 412 5555555",
  "address": "Calle 10, Edificio A",
  "sector": "Norte",
  "collection_mode": "Puerta a Puerta",
  "collection_center_id": "center-1",
  "created_at": "2026-03-09T15:30:00Z"
}

Update Generator

PUT /api/generators/:id Update an existing generator.

Path Parameters

id
string
required
Generator ID

Request Body

name
string
required
Generator name
rif
string
required
Tax identification number (RIF)
phone
string
required
Contact phone number
address
string
required
Physical address
sector
string
required
Sector or neighborhood
collectionMode
string
Collection mode
collectionCenterId
string
Associated collection center ID

Response

Returns the updated generator object.

Example Request

curl -X PUT http://localhost:4000/api/generators/gen-1 \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Restaurant El Sabor (Nueva Sede)",
    "rif": "J-12345678-9",
    "phone": "+58 414 1234567",
    "address": "Av. Bolívar, Local 12",
    "sector": "Centro",
    "collectionMode": "Puerta a Puerta",
    "collectionCenterId": "center-1"
  }'

Delete Generator

DELETE /api/generators/:id Delete a generator by its ID.
Deleting a generator will cascade delete all associated tickets due to the foreign key constraint.

Path Parameters

id
string
required
Generator ID

Response

ok
boolean
Returns true if deletion was successful

Example Request

curl -X DELETE http://localhost:4000/api/generators/gen-1

Example Response

{
  "ok": true
}

Error Response

{
  "error": "DB delete error"
}

Build docs developers (and LLMs) love