         device-identifier (:client (:metadata form-data))]
     (formmodel/add-form-data form-data form-id device-identifier)))
 
-(defn- routes []
+(defn- routes [mqtt]
   #{["/api/forms"                :get    (conj common-interceptors `http-get-all-forms)]
-    ["/api/forms"                :post   (conj common-interceptors check-auth `http-create-form)]
-    ["/api/forms/:form-key"      :delete (conj common-interceptors check-auth `http-delete-form-by-key)]
+    ["/api/forms"                :post   (conj common-interceptors check-auth (partial http-create-form mqtt)) :route-name :create-form]
+    ["/api/forms/:form-key"      :delete (conj common-interceptors check-auth (partial http-delete-form-by-key mqtt)) :route-name :delete-form]
     ["/api/forms/:form-key"      :get    (conj common-interceptors check-auth `http-get-form-by-form-key)]
     ;; todo: need to figure out why forms causes a route conflict
     ["/api/form/:form-id/submit"   :post   (conj common-interceptors check-auth `http-submit-form-data) :constraints {:form-id #"[0-9]+"}]


(defn http-create-form
  "Creates a new form."
  [request]
  (let [body    (get-in request [:json-params])
        team-id (:team_id body)
        form    (assoc  body :team_id team-id)]
      (if (s/valid? :spacon.models.form/spec form)
        (let [new-form (formmodel/add-form-with-fields! form)]
             (response/ok (formmodel/sanitize new-form)))
        (response/bad-request (str "failed to create form:" (s/explain-str :spacon.models.form/spec form))))))

(defn delete-form-by-id


(defn http-delete-form-by-key
  "Deletes all forms matching the form-key"
  [mqtt request]
  (let [form-key (URLDecoder/decode (get-in request [:path-params :form-key]))
        forms    (formmodel/find-by-form-key form-key)]
    (doall (map delete-form-by-id forms))
    (mqttapi/publish-scmessage mqtt "/config/update" (scm/map->SCMessage {:action (.value SCCommand/CONFIG_REMOVE_FORM)}))
    (response/ok (str "Deleted form " form-key))))

(defn http-submit-form-data
