chatformdocs
Blocks

Consent

Agreeing to terms, a waiver, a code of conduct. Put the wording in `description`. By default the only answer is yes; add decline=true when a refusal has to be a real answer you can route on: an eligibility gate, a policy someone may decline.

Advancedlegal_consent

Agreeing to terms, a waiver, a code of conduct. Put the wording in description. By default the only answer is yes; add decline=true when a refusal has to be a real answer you can route on: an eligibility gate, a policy someone may decline.

How it gets answered — matched exactly — never sent to a model.

Configuration

Fields specific to legal_consent. The fields every block has — id, ref, title, required, visibility, media, agentHints, prefillParam, identityField — are documented once.

legal_consent configuration
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "buttonLabel": {
      "type": "string",
      "maxLength": 60
    },
    "type": {
      "type": "string",
      "const": "legal_consent"
    },
    "consentText": {
      "type": "string",
      "minLength": 1,
      "maxLength": 10000
    },
    "allowDecline": {
      "default": false,
      "type": "boolean"
    },
    "agreeLabel": {
      "default": "I agree",
      "type": "string",
      "maxLength": 60
    },
    "declineLabel": {
      "default": "I do not agree",
      "type": "string",
      "maxLength": 60
    }
  },
  "required": [
    "id",
    "ref",
    "title",
    "type",
    "consentText"
  ],
  "$defs": {
    "__schema0": {
      "type": "object",
      "properties": {
        "op": {
          "type": "string",
          "enum": [
            "and",
            "or"
          ]
        },
        "conditions": {
          "default": [],
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "left": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "ref"
                      },
                      "ref": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9_]{1,40}$"
                      }
                    },
                    "required": [
                      "kind",
                      "ref"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "variable"
                      },
                      "name": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9_]{0,40}$"
                      }
                    },
                    "required": [
                      "kind",
                      "name"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "hidden"
                      },
                      "name": {
                        "type": "string",
                        "pattern": "^[a-zA-Z_][a-zA-Z0-9_.-]{0,60}$"
                      }
                    },
                    "required": [
                      "kind",
                      "name"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "literal"
                      }
                    },
                    "required": [
                      "kind"
                    ]
                  }
                ]
              },
              "op": {
                "type": "string",
                "enum": [
                  "eq",
                  "neq",
                  "gt",
                  "gte",
                  "lt",
                  "lte",
                  "contains",
                  "not_contains",
                  "starts_with",
                  "ends_with",
                  "matches_regex",
                  "is_empty",
                  "is_not_empty",
                  "is_checked",
                  "is_not_checked",
                  "includes",
                  "not_includes",
                  "ranked_above",
                  "ranked_below"
                ]
              },
              "value": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "boolean"
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                ]
              }
            },
            "required": [
              "left",
              "op"
            ]
          }
        },
        "groups": {
          "default": [],
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        }
      },
      "required": [
        "op"
      ]
    }
  }
}

In a generated draft these arrive as config pairs: decline=true to offer an explicit refusal; agree=<label>, declineLabel=<label> to relabel the two buttons.

What you receive

GET /v1/forms/{id} and every "next question" projects blocks through toPublicBlock. For the example above:

PublicBlock
{
  "id": "blk_legal001",
  "ref": "q_consent",
  "type": "legal_consent",
  "title": "One last thing",
  "required": true,
  "imageKey": null,
  "media": null,
  "consentText": "I agree to receive product updates.",
  "allowDecline": false,
  "agreeLabel": "I agree",
  "declineLabel": "I do not agree"
}

What you send

true. The stored answer records what was agreed to, and when. A block with allowDecline also accepts false — a recorded refusal, which a branch can route on; without it false is rejected.

type Answer = boolean;
curl -X POST https://api.chatform.in/v1/responses/{RESPONSE_ID}/answers \
  -H "x-api-key: $CHATFORM_SECRET_KEY" \
  -H "content-type: application/json" \
  -d '{"ref": "q_consent", "value": true}'

Errors

CodeWhenMessage
requiredan empty answer on a required blockThis question needs an answer.
consent_requiredfalse — this block does not offer a refusal; one with allowDecline stores it as accepted: falsePlease accept to continue.

On this page