Updating Forms with the REST API v2

Introduction

The /forms/[FORM_ID] endpoints can be used to update a form.

Authentication

See REST API v2 Authentication.

The capability gravityforms_create_form is required to use PUT requests at this endpoints.
This can be filtered using gform_rest_api_capability_put_forms.

Creating a Form

The /forms/[FORM_ID] endpoint can be used to create a single form.

Method

This endpoint accepts PUT requests in order to update forms.

Path

/gf/v2/forms/[FORM_ID]

Required Properties

The following properties are required.

KeyTypeDescription
fieldsarrayA collection of Field Object elements.
titlestringThe form title.

Optional Properties

The request body can also include any properties used to define the Form Object. Properties not explicitly set will be preserved from existing form. The form’s id property should not be explicitly set and cannot be updated via this endpoint.

Response

Success

A successful response will contain a JSON object with the complete updated Form Object.

KeyTypeDescription
[form_property]mixedForm properties of the Form Object.

Failure

A failed response will provide a JSON string of the error code and message.

KeyTypeDescription
codestringError code.
missing_form
not_found
messagestringHuman-readable error message.
data[status]integerHTTP response status code

Usage

cURL Request

curl --location --request PUT 'https://rocket.test/wp-json/gf/v2/forms/32' \
     --user 'ck_5f86565df60696c43af25f9194e106800770b8e9:cs_be0190310fefc061c564168670d0a96d68873c29' \
     --header 'Content-Type: application/json' \
     --data $'{
  "title": "Inquiry",
  "fields": [
    {
      "errorMessage": "",
      "layoutGridColumnSpan": "",
      "id": 1,
      "adminLabel": "",
      "nameFormat": "advanced",
      "inputs": [
        {
          "isHidden": true,
          "id": "1.2",
          "choices": [
            {
              "value": "Dr.",
              "text": "Dr."
            },
            {
              "value": "Miss",
              "text": "Miss"
            },
            {
              "value": "Mr.",
              "text": "Mr."
            },
            {
              "value": "Mrs.",
              "text": "Mrs."
            },
            {
              "value": "Ms.",
              "text": "Ms."
            },
            {
              "value": "Mx.",
              "text": "Mx."
            },
            {
              "value": "Prof.",
              "text": "Prof."
            },
            {
              "value": "Rev.",
              "text": "Rev."
            }
          ],
          "label": "Prefix",
          "autocompleteAttribute": "honorific-prefix",
          "inputType": "radio",
          "name": ""
        },
        {
          "id": "1.3",
          "label": "First",
          "name": "",
          "autocompleteAttribute": "given-name"
        },
        {
          "id": "1.4",
          "label": "Middle",
          "isHidden": true,
          "name": "",
          "autocompleteAttribute": "additional-name"
        },
        {
          "id": "1.6",
          "label": "Last",
          "name": "",
          "autocompleteAttribute": "family-name"
        },
        {
          "id": "1.8",
          "label": "Suffix",
          "isHidden": true,
          "name": "",
          "autocompleteAttribute": "honorific-suffix"
        }
      ],
      "labelPlacement": "",
      "productField": "",
      "label": "Name A",
      "description": "",
      "formId": 2634,
      "inputMask": false,
      "layoutGroupId": "dc68cb94",
      "type": "name",
      "inputMaskValue": "",
      "isRequired": false,
      "maxLength": "",
      "subLabelPlacement": "",
      "cssClass": "",
      "choices": "",
      "enableAutocomplete": false,
      "defaultValue": "",
      "descriptionPlacement": "",
      "inputType": "",
      "fields": "",
      "allowsPrepopulate": false,
      "size": "large",
      "conditionalLogic": "",
      "inputName": "",
      "autocompleteAttribute": "",
      "visibility": "visible",
      "inputMaskIsCustom": "",
      "noDuplicates": false,
      "enableEnhancedUI": 0,
      "placeholder": ""
    },
    {
      "errorMessage": "",
      "layoutGridColumnSpan": "",
      "id": 3,
      "adminLabel": "",
      "inputs": null,
      "labelPlacement": "",
      "calculationFormula": "",
      "productField": "",
      "errors": [],
      "label": "How did you hear about us?",
      "description": "",
      "formId": 2634,
      "inputMask": false,
      "layoutGroupId": "bc999d5b",
      "type": "select",
      "useRichTextEditor": false,
      "inputMaskValue": "",
      "validateState": true,
      "isRequired": false,
      "choices": [
        {
          "isSelected": false,
          "value": "Online",
          "price": "",
          "text": "Online"
        },
        {
          "isSelected": false,
          "value": "Friend",
          "price": "",
          "text": "Friend"
        },
        {
          "isSelected": false,
          "value": "Newspaper",
          "price": "",
          "text": "Newspaper"
        }
      ],
      "maxLength": "",
      "subLabelPlacement": "",
      "cssClass": "",
      "calculationRounding": "",
      "multipleFiles": false,
      "displayAllCategories": false,
      "enableAutocomplete": false,
      "defaultValue": "",
      "enablePrice": "",
      "descriptionPlacement": "",
      "maxFiles": "",
      "inputType": "",
      "fields": "",
      "allowsPrepopulate": false,
      "size": "large",
      "conditionalLogic": "",
      "enableCalculation": "",
      "inputName": "",
      "autocompleteAttribute": "",
      "visibility": "visible",
      "inputMaskIsCustom": false,
      "noDuplicates": false,
      "disableQuantity": false,
      "enableEnhancedUI": 0,
      "placeholder": ""
    }
  ]
}'

Response

{
  "title": "Inquiry",
  "fields": [
    {
      "type": "name",
      "id": 1,
      "formId": "32",
      "label": "Name A",
      "adminLabel": "",
      "isRequired": false,
      "size": "large",
      "errorMessage": "",
      "visibility": "visible",
      "nameFormat": "advanced",
      "inputs": [
        {
          "id": "1.2",
          "label": "Prefix",
          "name": "",
          "autocompleteAttribute": "honorific-prefix",
          "choices": [
            {
              "text": "Dr.",
              "value": "Dr."
            },
            {
              "text": "Miss",
              "value": "Miss"
            },
            {
              "text": "Mr.",
              "value": "Mr."
            },
            {
              "text": "Mrs.",
              "value": "Mrs."
            },
            {
              "text": "Ms.",
              "value": "Ms."
            },
            {
              "text": "Mx.",
              "value": "Mx."
            },
            {
              "text": "Prof.",
              "value": "Prof."
            },
            {
              "text": "Rev.",
              "value": "Rev."
            }
          ],
          "isHidden": true,
          "inputType": "radio"
        },
        {
          "id": "1.3",
          "label": "First",
          "name": "",
          "autocompleteAttribute": "given-name"
        },
        {
          "id": "1.4",
          "label": "Middle",
          "name": "",
          "autocompleteAttribute": "additional-name",
          "isHidden": true
        },
        {
          "id": "1.6",
          "label": "Last",
          "name": "",
          "autocompleteAttribute": "family-name"
        },
        {
          "id": "1.8",
          "label": "Suffix",
          "name": "",
          "autocompleteAttribute": "honorific-suffix",
          "isHidden": true
        }
      ],
      "description": "",
      "allowsPrepopulate": false,
      "inputMask": false,
      "inputMaskValue": "",
      "inputMaskIsCustom": "",
      "maxLength": "",
      "inputType": "",
      "labelPlacement": "",
      "descriptionPlacement": "",
      "subLabelPlacement": "",
      "placeholder": "",
      "cssClass": "",
      "inputName": "",
      "noDuplicates": false,
      "defaultValue": "",
      "enableAutocomplete": false,
      "autocompleteAttribute": "",
      "choices": "",
      "conditionalLogic": "",
      "productField": "",
      "layoutGridColumnSpan": "",
      "enableEnhancedUI": 0,
      "layoutGroupId": "dc68cb94",
      "fields": "",
      "pageNumber": 1
    },
    {
      "type": "select",
      "id": 3,
      "formId": "32",
      "label": "How did you hear about us?",
      "adminLabel": "",
      "isRequired": false,
      "size": "large",
      "errorMessage": "",
      "visibility": "visible",
      "validateState": true,
      "inputs": null,
      "choices": [
        {
          "text": "Online",
          "value": "Online",
          "isSelected": false,
          "price": ""
        },
        {
          "text": "Friend",
          "value": "Friend",
          "isSelected": false,
          "price": ""
        },
        {
          "text": "Newspaper",
          "value": "Newspaper",
          "isSelected": false,
          "price": ""
        }
      ],
      "description": "",
      "allowsPrepopulate": false,
      "inputMask": false,
      "inputMaskValue": "",
      "inputMaskIsCustom": false,
      "maxLength": "",
      "inputType": "",
      "labelPlacement": "",
      "descriptionPlacement": "",
      "subLabelPlacement": "",
      "placeholder": "",
      "cssClass": "",
      "inputName": "",
      "noDuplicates": false,
      "defaultValue": "",
      "enableAutocomplete": false,
      "autocompleteAttribute": "",
      "conditionalLogic": "",
      "productField": "",
      "layoutGridColumnSpan": "",
      "enablePrice": "",
      "enableEnhancedUI": 0,
      "layoutGroupId": "bc999d5b",
      "multipleFiles": false,
      "maxFiles": "",
      "calculationFormula": "",
      "calculationRounding": "",
      "enableCalculation": "",
      "disableQuantity": false,
      "displayAllCategories": false,
      "useRichTextEditor": false,
      "errors": [],
      "fields": "",
      "pageNumber": 1
    }
  ],
  "version": "2.7.13",
  "id": "32",
  "notifications": {
    "64f8960c955be": {
      "id": "64f8960c955be",
      "name": "Custom Notification",
      "service": "wordpress",
      "event": "form_submission",
      "toType": "email",
      "toEmail": "[email protected]",
      "routing": null,
      "fromName": "",
      "from": "[email protected]",
      "replyTo": "",
      "bcc": "",
      "subject": "{ip}",
      "message": "{all_fields}",
      "disableAutoformat": false,
      "notification_conditional_logic_object": "",
      "notification_conditional_logic": "0",
      "conditionalLogic": null,
      "to": "[email protected]",
      "cc": "",
      "enableAttachments": false
    }
  },
  "confirmations": {
    "64f895bb4ae9a": {
      "id": "64f895bb4ae9a",
      "name": "Default Confirmation",
      "isDefault": true,
      "type": "page",
      "message": "Thanks for contacting us! We will get in touch with you shortly.",
      "url": "",
      "pageId": "27",
      "queryString": "",
      "event": "",
      "disableAutoformat": false,
      "page": "27",
      "conditionalLogic": []
    }
  },
  "nextFieldId": 4,
  "is_active": "0",
  "date_created": "2023-09-06 15:07:39",
  "is_trash": "0"
}