Skip to main content

Unavailabilities (customer)

Record availability intervals per plant (curtailment, unavailability, etc.). All times are stored in UTC. Each row belongs to the authenticated customer; plant_id must match an existing plant name for that account.

Base path: /api/v0/unavailabilities/

Requires Bearer token.


JSON schema (English)

FieldTypeRequired (create)Description
plant_idstringYesUnique plant identifier (same as the plant name in Plants).
start_time_utcstring (date-time)YesInterval start in UTC (ISO 8601).
end_time_utcstring (date-time)YesInterval end in UTC; must be after start_time_utc.
available_power_mwnumber (≥ 0)YesAvailable power, always in MW.
availability_typestringYesOne of: CURTAILMENT, UNAVAILABILITY, OTHER.
observationsstringNoFree-text notes.
source_unitstringNoOriginal unit from the client: MW, kW, or %.
source_valuenumberNoOriginal numeric value from the client.
timezone_sourcestringNoIANA timezone if the client entered local time (e.g. Europe/Madrid, Atlantic/Canary).
idUUIDSet by the server.
created_atdate-timeSet by the server.
updated_atdate-timeUpdated on each change.

List unavailabilities

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

Optional query: plant_id — restrict to one plant.

Request

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

Filter by plant:

curl --request GET \
--url 'https://api.ravenwits.com/api/v0/unavailabilities/?plant_id=MY_PLANT_NAME' \
--header 'Authorization: Bearer {your-token}'

Response

200 OK — JSON array of objects matching the schema above.


Create unavailability

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

Request

curl --request POST \
--url 'https://api.ravenwits.com/api/v0/unavailabilities/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {your-token}' \
--data '{
"plant_id": "NORTH_PLANT",
"start_time_utc": "2025-03-14T08:00:00Z",
"end_time_utc": "2025-03-14T18:00:00Z",
"available_power_mw": 12.5,
"availability_type": "UNAVAILABILITY",
"observations": "Scheduled work",
"source_unit": "MW",
"source_value": 12.5,
"timezone_source": "Europe/Madrid"
}'

Response

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

400 Bad Request — validation error (unknown plant_id, bad enum, end before start, negative MW, etc.).


Get one record

GET https://api.ravenwits.com/api/v0/unavailabilities/{id}/

id is the UUID. Only the owning customer can read it.


Update unavailability

PATCH https://api.ravenwits.com/api/v0/unavailabilities/{id}/ — partial update.

PUT https://api.ravenwits.com/api/v0/unavailabilities/{id}/ — full replace (same required fields as create).


Delete unavailability

DELETE https://api.ravenwits.com/api/v0/unavailabilities/{id}/

Delete one unavailability record owned by the authenticated customer.

Request

curl --request DELETE \
--url 'https://api.ravenwits.com/api/v0/unavailabilities/{id}/' \
--header 'Authorization: Bearer {your-token}'

Response

204 No Content — deleted successfully.

404 Not Found — unknown id or record is not owned by the authenticated customer.


Errors

StatusMeaning
401Missing or invalid Bearer token.
404Unknown id or not owned by the customer.
400Validation error.

Notes

  • plant_id is validated against your Plants list; create plants first via /api/v0/plants/.
  • Run migrations after deploy: python manage.py migrate.