formtoDashboard

Define your fields

A definition lists a form's fields: their names, types, labels and whether they are required. formto uses it to validate responses, label them in emails and the dashboard, and generate form code.

json
{
  "version": 2,
  "title": "Quote request",
  "fields": {
    "name": { "type": "string", "label": "Your name", "required": true },
    "email": { "type": "email", "label": "Email", "required": true },
    "service": { "type": "select", "label": "Service", "options": [{ "value": "mowing" }, { "value": "hedges" }] },
    "details": { "type": "text", "label": "Anything else?" }
  },
  "fieldOrder": ["name", "email", "service", "details"]
}

Field types: string, text, email, phone, url, number, boolean, date, datetime, select, multiselect, rating, scale, file and hidden. Names are letters, digits, _, . or -; names starting with _ are reserved for formto.

Set a definition

sh
FORM_ID=$(curl -fsS https://api.formto.io/v2/forms \
  -H "Authorization: Bearer $FORMTO_TOKEN" -H 'content-type: application/json' \
  -d '{"name":"Quote request"}' | node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).id')
curl -fsS -X PUT "https://api.formto.io/v2/forms/$FORM_ID/definition" \
  -H "Authorization: Bearer $FORMTO_TOKEN" -H 'content-type: application/json' \
  -d '{"version":2,"fields":{"name":{"type":"string","required":true},"email":{"type":"email","required":true}}}'

Changing a definition never touches responses you already have.