Introduction
The /forms
endpoints can be used to create forms.
Authentication
See REST API v2 Authentication.
The capability gravityforms_create_form
is required to use POST
requests at these endpoints.
This can be filtered using gform_rest_api_capability_post_forms.
Creating a Form
The /forms
endpoint can be used to create a single form.
Method
This endpoint accepts POST
requests in order to create forms.
Path
/gf/v2/forms
Required Properties
The following properties are required.
Key | Type | Description |
---|---|---|
fields | array | A collection of Field Object elements. |
title | string | The form title. |
Optional Properties
The request body can also include any properties used to define the Form Object. The form’s id property should not be explicitly set.
Response
Success
A successful response will contain a JSON object of the newly created Form Object.
Key | Type | Description |
---|---|---|
[form_property] | mixed | Form properties of the Form Object. |
Failure
A failed response will provide a JSON string of the error code and message.
Key | Type | Description |
---|---|---|
code | string | Error code.missing_form |
message | string | Human-readable error message. |
data[status] | integer | HTTP response status code |
Usage
cURL Request
curl --location --request POST 'https://rocket.test/wp-json/gf/v2/forms' \
--user 'ck_5f86565df60696c43af25f9194e106800770b8e9:cs_be0190310fefc061c564168670d0a96d68873c29' \
--header 'Content-Type: application/json' \
--data $'{
"title": "Inquiry Form",
"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 Form",
"fields": [
{
"type": "name",
"id": 1,
"formId": 31,
"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": 31,
"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": 31,
"markupVersion": 2,
"notifications": [],
"confirmations": {
"64f793366215f": {
"id": "64f793366215f",
"name": "Default Confirmation",
"isDefault": true,
"type": "message",
"message": "Thanks for contacting us! We will get in touch with you shortly.",
"url": "",
"pageId": "",
"queryString": ""
}
},
"nextFieldId": 4,
"is_active": "1",
"date_created": "2023-09-05 20:44:38",
"is_trash": "0"
}