   client.print("Host: ");
   client.println(serverAddress);
   client.println("Connection: close");
+}
+
+bool handlerIsRegistered() {
+  Serial.println("> handlerIsRegistered()");
+  
+  bool result = false;
+  
+  Serial.println("trying to determine whether the handler is already registered");
+
+  if (connectToAPI()) {
+    client.print("GET /api/handlers/");
+    client.print(ESP.getFlashChipId());
+    client.println(" HTTP/1.1");
+    sendHTTPHeader();
+    client.println();
+
+    delay(10);
+    String line = client.readStringUntil('\r');
+
+    if (line.startsWith("HTTP/1.1 404 Not Found")) {
+      Serial.println("handler not yet registered");
+      result = false;
+    } else if (line.startsWith("HTTP/1.1 200 OK")) {
+      // TODO check if light count has changed and delete existing and reregister if changed
+      
+      Serial.println("handler already registered");
+      result = true;
+    } else {
+      Serial.print(line);
+      while(client.available()) {
+        String line = client.readStringUntil('\r');
+        Serial.print(line);
+      }
+      Serial.println("");
+      Serial.println("unrecognized status code or error");
+    }
+
+    client.stop();
+
+  }
+  
+  Serial.print("< ");
+  Serial.println(result);
+  
+  return result;
 }
 
 int registerHandler() { 

  Serial.println("===============================");
}

void setup()
{
  Serial.begin(115200);

  WiFiManager wifiManager;

  String apName = String(AUTOCONFIG_ACCESSPOINT_NAME) + String("_") + String(ESP.getChipId());
  char apNameBuffer[apName.length()];
  apName.toCharArray(apNameBuffer, apName.length());
  
  if(!wifiManager.autoConnect(apNameBuffer)) {
    Serial.println("failed to connect to WiFi and hit timeout");

    }

    client.stop();
  }
  
  Serial.print("< ");
