Forms

Add a field to a form

POST/forms/{form_id}/fields

Adds a field to the form and returns it with a Location. type is required; without order the field goes last. Put requiredness in validator, such as required|string. page_id must be a page of this form and option_preset_id a live preset, else 422 exists. conditions may target only fields of this form. To add fields that point at each other, send them together to POST /forms. dry_run shows the result without saving it. Emits form_field.created; no email. DELETE /forms/{form_id}/fields/{id} undoes it.

Path parameters

  • form_idstring (uuid)Required#

    The form's id, a uuid. An unknown id, or a hidden form, returns 404.

Query parameters

  • dry_runboolean#

    Validate and run the call without committing it, returning what the real call would return with meta.dry_run set.

Headers

  • Idempotency-Keystring#

    Makes a retry safe. Send a new UUID for each new request and reuse it only to retry that request; the first response is replayed for 24 hours.

Request body

application/json, required · FormFieldCreate

  • typestringRequired#

    The field type, such as TEXT, BIGTEXT, INTEGER, EMAIL, DATE, DROPDOWN, CHECKBOX, CURRENCY, OPTION_SELECT, FILE_UPLOAD or SIGNATURE.

  • labelstring | null#

    The question shown to the person filling in the form.

  • namestring | null#

    The field's short name.

  • descriptionstring | null#

    Help text shown under the question.

  • referencestring | null#

    A key that stays stable across edits, unique within the form.

  • validatorstring | null#

    Validation rules separated by a pipe, such as required|string.

  • placeholderstring | null#

    Placeholder text.

  • pre_population_keystring | null#

    The profile value that pre-fills this field.

  • backfillboolean | null#

    Whether the answer is written back to the profile.

  • orderinteger | null#

    The field's position within the form.

  • page_idstring | null#

    A page of this form to place the field on.

  • option_preset_idstring | null#

    A live option preset a dropdown field takes its options from.

  • optionsarray | object | null#

    The options of a dropdown or similar field. A list for most types; an object for a DOCUSIGN field.

  • condition_logicstring | null#

    Whether all conditions (AND) or any one (OR) must hold. AND unless set.

    One of: AND, OR
  • conditionsarray | null#

    Display conditions. Every controlling field must be a field of this form.

{
  "type": "TEXT",
  "label": "Spouse name",
  "reference": "spouse_name",
  "validator": "required|string",
  "order": 2,
  "conditions": [
    {
      "against_field_reference": "marital_status",
      "operator": "=",
      "value": "married"
    }
  ]
}

Responses

201

The field was added.

FormField
{
  "data": {
    "id": "9a9d1c5e-4f2b-4c8e-9a7d-2f1e6b3c4d5a",
    "label": "string",
    "name": "string",
    "description": "string",
    "type": "string",
    "reference": "string",
    "validator": "string",
    "placeholder": "string",
    "pre_population_key": "string",
    "backfill": true,
    "order": 1,
    "page_id": "9a9d1c5e-4f2b-4c8e-9a7d-2f1e6b3c4d5a",
    "option_preset_id": "9a9d1c5e-4f2b-4c8e-9a7d-2f1e6b3c4d5a",
    "options": [
      null
    ],
    "required": true,
    "conditions": [
      {
        "against_field_id": "9a9d1c5e-4f2b-4c8e-9a7d-2f1e6b3c4d5a",
        "against_field_reference": "string",
        "operator": "string",
        "value": "string"
      }
    ],
    "condition_logic": "AND"
  }
}
401

Authentication failed. error.code is one of invalid_token, expired, revoked.

Error
403

Authorization failed. error.code is one of org_disabled, ip_blocked, missing_scope, scope_disabled, user_disabled.

Error
404

Resource not found (error.code = not_found).

Error
409

The request conflicts with existing state (error.code = conflict), e.g. a compliance flow with the requested name already exists.

Error
422

The request can't be processed (HTTP 422): validation_failed with one ErrorDetail per problem, or a code documented on the operation.

Error
429

Rate limit exceeded (error.code = rate_limited).

Error

Examples

curl -X POST https://your-org-domain/kong/core/api/v2/forms/{form_id}/fields\
  -H "Authorization: Bearer $HELM_API_KEY"\
  -H "Content-Type: application/json"\
  -d '{
  "type": "TEXT",
  "label": "Spouse name",
  "reference": "spouse_name",
  "validator": "required|string",
  "order": 2,
  "conditions": [
    {
      "against_field_reference": "marital_status",
      "operator": "=",
      "value": "married"
    }
  ]
}'