Form Rules API
A form's rules are the validation rules of its fields. The KwesForms script sets them for you from your HTML. If your form does not use the script, set them with this call. New to the API? Start with the overview.
Set Form Rules
POST /api/v1/forms/{form}/rules Bronze Plan
Sets a form's fields and the validation rules of each. A form needs rules before you can create submissions for it through the API.
Every call replaces all of the form's rules, so always send every field.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
form |
path | integer | Yes | The form's ID. |
fields |
body | array | Yes | The form's fields, one object per field. |
fields[].name |
body | string | Yes | The field's name. |
fields[].rules |
body | array | Yes | The field's validation rules, at least one. For a field that can hold anything, send ["nullable"]. |
fields[].type |
body | string | No | The kind of field. Default text. |
type is one of text, email, number, tel, url, file, textarea, select, radio, checkbox, date, time, datetime-local, month, week, color, range or hidden.
curl -X POST "https://kwesforms.com/api/v1/forms/7/rules" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"fields": [
{ "name": "name", "type": "text", "rules": ["required", "max:255"] },
{ "name": "email", "type": "email", "rules": ["required", "email"] },
{ "name": "message", "type": "textarea", "rules": ["nullable"] }
]
}'
{
"status": "success",
"message": "Form rules synced successfully"
}
| Status | Message | Why |
|---|---|---|
400 |
This endpoint is only available for forms created with store_version 2. |
This call is not available for this form's account. Contact support. |
Notice anything wrong in our docs? Let us know.