Skip to main content

Plants (customer)

Manage generation plants for the authenticated customer. Each plant belongs to the customer tied to the Bearer token. Other customers’ plants are never returned.

Base path: /api/v0/plants/

Requires Bearer token (same as login).


Data model (JSON)

FieldTypeRequired (create)Description
idUUIDSet by server.
namestringYesPlant name or external ID (unique per customer; often matches forecast plant codes).
latnumberYesLatitude, decimal degrees (e.g. 42.94972).
lonnumberYesLongitude, decimal degrees (e.g. -3.67893).
installed_capacity_mwnumberYesInstalled capacity (MW).
nominal_capacity_mwnumberYesNominal capacity (MW).
areastringYesRegion/map code (e.g. ESP).
technology_typestringYes"eolica" or "solar".
last_training_cnn_atstringNoLast CNN training time, e.g. YYYY-MM-DD HH:MM, or empty.
last_training_trees_atstringNoLast tree-model training time, or empty.
agrupationstringNoOptional cluster for aggregated forecasts.
customer_display_namestringNoOptional label on this record.
timezonestringNoIANA timezone (e.g. Europe/Madrid).
created_atISO datetimeServer timestamps.
updated_atISO datetime

List plants

GET https://api.ravenwits.com/api/v0/plants/

Returns a JSON array of plant objects for the logged-in customer.

Request

curl --request GET \
--url 'https://api.ravenwits.com/api/v0/plants/' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your-token}'

Response

200 OK — array of plants, e.g.:

[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "NORTH_PLANT",
"lat": "42.9497200",
"lon": "-3.6789300",
"installed_capacity_mw": "18.000",
"nominal_capacity_mw": "18.000",
"area": "ESP",
"technology_type": "eolica",
"last_training_cnn_at": "2025-01-15 08:30",
"last_training_trees_at": "",
"agrupation": "",
"customer_display_name": "",
"timezone": "Europe/Madrid",
"created_at": "2025-03-01T12:00:00Z",
"updated_at": "2025-03-01T12:00:00Z"
}
]

Create plant

POST https://api.ravenwits.com/api/v0/plants/

Body: JSON object with required fields (see table). Optional fields may be omitted or "".

Request

curl --request POST \
--url 'https://api.ravenwits.com/api/v0/plants/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your-token}' \
--data '{
"name": "NORTH_PLANT",
"lat": 42.94972,
"lon": -3.67893,
"installed_capacity_mw": 18.0,
"nominal_capacity_mw": 18.0,
"area": "ESP",
"technology_type": "eolica",
"last_training_cnn_at": "",
"last_training_trees_at": "",
"agrupation": "",
"customer_display_name": "",
"timezone": "Europe/Madrid"
}'

Response

201 Created — full plant object including id, created_at, updated_at.

400 Bad Request — validation errors (e.g. duplicate name for that customer).


Get one plant

GET https://api.ravenwits.com/api/v0/plants/{plant_id}/

plant_id is the plant UUID. Only plants owned by the customer are visible.


Update plant

PATCH https://api.ravenwits.com/api/v0/plants/{plant_id}/

Send only fields to change (partial update). To rename a plant, include the new name in the body.

PUT https://api.ravenwits.com/api/v0/plants/{plant_id}/

Full replacement: send all writable fields (same as create).

Request (PATCH example)

curl --request PATCH \
--url 'https://api.ravenwits.com/api/v0/plants/{plant_id}/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-token}' \
--data '{"nominal_capacity_mw": 20.0, "last_training_cnn_at": "2025-03-14 10:00"}'

Response

200 OK — updated plant object.

404 Not Found — wrong UUID or plant belongs to another customer.


Errors

StatusMeaning
401Missing or invalid Bearer token.
404Plant not found or not owned by customer.
400Validation error (e.g. duplicate name, invalid technology_type).

Notes

  • Training timestamps are stored as free-form strings (e.g. YYYY-MM-DD HH:MM) so you can align with existing pipelines; they are not validated as datetimes by the API.
  • Junior spec correction: Use HH:MM (hours:minutes), not HH:SS, for clock time unless you intentionally store seconds.
  • Run migrations after deploy so the customers_customerplant table exists (python manage.py migrate).