myCistern

API Reference

Technical API documentation for developers

This document describes the REST API for integrating WaterGuard data into your own systems. The API allows dealers and developers to retrieve device data, manage configurations, and receive real-time events via webhooks.

Authentication

All API requests require authentication using an API key. Contact your myCistern account manager to obtain an API key.

Request Headers

Authorization: Bearer <your-api-key>
Content-Type: application/json

Rate Limiting

The API enforces rate limiting to ensure fair usage. Limits are applied per API key.

TierRequests per minuteRequests per hour
Standard601000
Premium3005000

Exceeding the rate limit returns a 429 Too Many Requests response.

Base URL

All API endpoints are relative to the following base URL:

https://api.mycistern.com/v1

Endpoints

List Devices

Retrieves a list of all WaterGuard devices associated with your account.

GET /devices

Response

{
  "devices": [
    {
      "id": "wg-123456",
      "name": "Main Cistern",
      "model": "refill",
      "firmware_version": "2.1.0",
      "online": true,
      "last_seen": "2025-01-15T14:30:00Z"
    }
  ]
}

Get Device Details

Retrieves detailed information about a specific device.

GET /devices/{device_id}

Parameters

ParameterTypeDescription
device_idstringThe unique identifier of the device

Response

{
  "id": "wg-123456",
  "name": "Main Cistern",
  "model": "refill",
  "firmware_version": "2.1.0",
  "online": true,
  "last_seen": "2025-01-15T14:30:00Z",
  "cistern": {
    "capacity_liters": 5000,
    "current_level_percent": 72,
    "refill_threshold_percent": 30,
    "high_level_alert_percent": 95
  },
  "sensor": {
    "status": "ok",
    "last_reading": "2025-01-15T14:30:00Z",
    "signal_quality": "good"
  },
  "filter": {
    "status": "clean",
    "last_cleaned": "2025-01-01T10:00:00Z"
  }
}

Get Water Level History

Retrieves historical water level data for a device.

GET /devices/{device_id}/history

Parameters

ParameterTypeDefaultDescription
device_idstringThe unique identifier of the device
fromISO 860124 hours agoStart of the time range
toISO 8601nowEnd of the time range
intervalstring1hAggregation interval: 5m, 15m, 1h, 1d

Response

{
  "device_id": "wg-123456",
  "interval": "1h",
  "data_points": [
    {
      "timestamp": "2025-01-15T13:00:00Z",
      "level_percent": 70,
      "temperature_celsius": 12.5
    },
    {
      "timestamp": "2025-01-15T14:00:00Z",
      "level_percent": 72,
      "temperature_celsius": 12.3
    }
  ]
}

Update Device Configuration

Updates the configuration of a specific device.

PATCH /devices/{device_id}/config

Request Body

{
  "name": "Main Cistern - Garden",
  "refill_threshold_percent": 25,
  "high_level_alert_percent": 90,
  "cistern_capacity_liters": 5000
}

Response

{
  "success": true,
  "device_id": "wg-123456",
  "updated_fields": ["name", "refill_threshold_percent"]
}

Trigger Relay Output (Refill Only)

Manually triggers a relay output on a WaterGuard Refill device.

POST /devices/{device_id}/relay

Request Body

{
  "output": 1,
  "action": "activate",
  "duration_seconds": 60
}

Parameters

FieldTypeDescription
outputintegerRelay output number (1 or 2)
actionstringactivate or deactivate
duration_secondsintegerDuration in seconds (omit for indefinite)

Webhooks

Webhooks allow your system to receive real-time events from WaterGuard devices. Configure webhook endpoints in the myCistern dashboard.

Register a Webhook

POST /webhooks

Request Body

{
  "url": "https://your-server.com/webhooks/mycistern",
  "events": ["device.online", "device.offline", "level.low", "filter.dirty", "error"],
  "secret": "your-webhook-secret"
}

Supported Events

EventDescription
device.onlineDevice came online
device.offlineDevice went offline
level.lowWater level dropped below threshold
level.highWater level exceeded high alert threshold
filter.dirtyFilter requires cleaning
errorDevice reported an error
firmware.updatedFirmware update completed

Webhook Payload

{
  "event": "level.low",
  "device_id": "wg-123456",
  "timestamp": "2025-01-15T14:30:00Z",
  "data": {
    "level_percent": 28,
    "threshold_percent": 30
  }
}

Webhook Signature Verification

Each webhook request includes a signature header for verification:

X-MyCistern-Signature: t=1705314600,v1=abc123def456...

The signature is computed using HMAC-SHA256 with your webhook secret:

HMAC-SHA256(secret, timestamp + "." + request_body)

Data Formats

Timestamps

All timestamps are in ISO 8601 format (UTC):

2025-01-15T14:30:00Z

Units

MeasurementUnit
Water levelPercentage (0–100)
Cistern capacityLiters
TemperatureCelsius
DurationSeconds

Error Responses

{
  "error": {
    "code": "device_not_found",
    "message": "No device found with the specified ID",
    "details": {
      "device_id": "wg-invalid"
    }
  }
}
HTTP StatusError CodeDescription
400invalid_requestMalformed request body
401unauthorizedMissing or invalid API key
404device_not_foundDevice ID does not exist
429rate_limit_exceededToo many requests
500internal_errorServer error

Source document: WG-API-EN-v1

Source pages: 1, 2, 3, 4

Content status: Source-backed

On this page