Skip to main content
You can attach a validation object to any question to enforce the format of the answer. Validation runs in two places: during the call (triggering a retry if the answer doesn’t match), and when you manually correct an answer via PATCH /api/v1/agents/{agent_id}/conversations/{conversation_id}/form_data.

Validation object structure

Add a validation key to any question object and set its type to one of the rule names below. Some rules accept additional parameters in a rules sub-object.
For rules that take no parameters (such as date), you can omit rules entirely.

Available rules

Validates that the answer is a 10-digit Indian mobile or landline number.Parameters:Behaviour:
  • Strips leading +91, 91, or 0 prefixes before counting digits.
  • Rejects numbers where all digits are the same (e.g., 9999999999).
Requires the answer to be at least a given number of characters long.Parameters:
Requires the answer to contain exactly the specified number of digits, ignoring non-digit characters.Parameters:
Requires the numeric answer to fall within a specified range. You can supply one or both bounds.Parameters:
Requires the answer to be a valid calendar date in DD-MM-YYYY format.Parameters: None.
An alias for the date rule. Behaves identically — use whichever name feels clearer in your configuration.Parameters: None.
Requires the answer to be a valid DD-MM-YYYY date that is today or in the past. Useful for fields like date of birth or symptom onset date.Parameters: None.
Requires the answer to be a valid DD-MM-YYYY date that is after today. Useful for appointment or follow-up dates.Parameters: None.
Validates the answer against a regular expression you define. Include a message to tell the agent (and the caller) what format is expected.Parameters:
Describes a validation rule in plain English, enforced by the LLM during the call. Use this for rules that are difficult to express as a pattern — for example, requiring a valid Indian state name.Parameters:
The free_text rule is only enforced during the live call. It is not checked when you manually patch form data via PATCH /api/v1/.../form_data. Use a regex or other structural rule if you need server-side enforcement on manual edits.

Failure response

When validation fails during a PATCH /api/v1/agents/{agent_id}/conversations/{conversation_id}/form_data request, you receive HTTP 400. The response body identifies every field that failed:
object
A map of field names to failure details. Each entry describes one field that failed validation.
Nothing is saved if any field fails validation. Fix all reported fields and resubmit the entire patch.