Deleting Forms with the REST API v2

Introduction

The /forms/[FORM_ID] endpoint can be used to trash or delete forms.

Note: By default, calling a DELETE request on this endpoint sends the specified form to the trash. If the form is already in the trash, then repeating this request will not delete the form permanently but the response code will be 410 (Gone). Use the force parameter to delete the form permanently.

Authentication

See REST API v2 Authentication.

The Gravity Forms gravityforms_delete_forms is required to use DELETE requests at this endpoint.
This can be filtered using gform_rest_api_capability_delete_forms.

Deleting a Form

The /forms/[FORM_ID] endpoint is used to delete a single form.

Method

This endpoint accepts DELETE requests in order to trash (or optionally delete) forms.

Path

/gf/v2/forms/[FORM_ID]

Required Properties

There are no required properties.

Optional Properties

The request URL can also include the following parameters.

KeyTypeDescription
forceintegerDefault is 0.
Set to 1 in order to permanently delete an entry.

Response

Success

A successful response when trashing will contain a JSON object with the form details.

KeyTypeDescription
[form_property]mixedForm properties of the Form Object.

A successful response when using the force parameter to permanently delete will contain a JSON object with the form details.

KeyTypeDescription
deletedbooleantrue indicating permanent deletion.
previousForm ObjectThe deleted form.

Failure

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

KeyTypeDescription
codestringError code.
gf_form_invalid_id
gf_cannot_delete
gf_already_trashed
messagestringHuman-readable error message.
data[status]integerHTTP response status code

Usage

cURL Request

curl --location --request DELETE 'https://rocket.test/wp-json/gf/v2/forms/32' \
     --user 'ck_5f86565df60696c43af25f9194e106800770b8e9:cs_be0190310fefc061c564168670d0a96d68873c29'

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": "1"
}

cURL Request

curl --location --request DELETE 'https://rocket.test/wp-json/gf/v2/forms/29?force=1' \
     --user 'ck_5f86565df60696c43af25f9194e106800770b8e9:cs_be0190310fefc061c564168670d0a96d68873c29'

Response

{
  "deleted": true,
  "previous": {
    "fields": [
      {
        "type": "address",
        "id": 1,
        "formId": 29,
        "label": "Address",
        "adminLabel": "",
        "isRequired": false,
        "size": "large",
        "errorMessage": "",
        "visibility": "visible",
        "addressType": "international",
        "inputs": [
          {
            "id": "1.1",
            "label": "Street Address",
            "name": "",
            "autocompleteAttribute": "address-line1"
          },
          {
            "id": "1.2",
            "label": "Address Line 2",
            "name": "",
            "autocompleteAttribute": "address-line2"
          },
          {
            "id": "1.3",
            "label": "City",
            "name": "",
            "autocompleteAttribute": "address-level2"
          },
          {
            "id": "1.4",
            "label": "State \/ Province",
            "name": "",
            "autocompleteAttribute": "address-level1"
          },
          {
            "id": "1.5",
            "label": "ZIP \/ Postal Code",
            "name": "",
            "autocompleteAttribute": "postal-code"
          },
          {
            "id": "1.6",
            "label": "Country",
            "name": "",
            "autocompleteAttribute": "country-name"
          },
          {
            "id": "1.geolocation_latitude",
            "label": "Latitude",
            "name": "",
            "isHidden": true
          },
          {
            "id": "1.geolocation_longitude",
            "label": "Longitude",
            "name": "",
            "isHidden": true
          }
        ],
        "description": "",
        "allowsPrepopulate": false,
        "inputMask": false,
        "inputMaskValue": "",
        "inputMaskIsCustom": false,
        "maxLength": "",
        "inputType": "",
        "labelPlacement": "",
        "descriptionPlacement": "",
        "subLabelPlacement": "",
        "placeholder": "",
        "cssClass": "",
        "inputName": "",
        "noDuplicates": false,
        "defaultValue": "",
        "enableAutocomplete": false,
        "autocompleteAttribute": "",
        "choices": "",
        "conditionalLogic": "",
        "defaultCountry": "",
        "defaultProvince": "",
        "copyValuesOptionLabel": "",
        "productField": "",
        "layoutGridColumnSpan": "",
        "defaultState": "",
        "enableCopyValuesOption": "",
        "copyValuesOptionDefault": "",
        "copyValuesOptionField": "",
        "enableEnhancedUI": 0,
        "layoutGroupId": "84a47262",
        "multipleFiles": false,
        "maxFiles": "",
        "calculationFormula": "",
        "calculationRounding": "",
        "enableCalculation": "",
        "disableQuantity": false,
        "displayAllCategories": false,
        "useRichTextEditor": false,
        "ggeolocationEnableGeolocationSuggestions": true,
        "pageNumber": 1,
        "fields": ""
      }
    ],
    "button": {
      "type": "text",
      "text": "",
      "imageUrl": "",
      "width": "auto",
      "location": "bottom",
      "layoutGridColumnSpan": 12
    },
    "title": "Test Geo",
    "description": "",
    "version": "2.7.9",
    "id": 29,
    "markupVersion": 2,
    "nextFieldId": 2,
    "is_active": "1",
    "date_created": "2023-07-10 15:27:16",
    "is_trash": "1",
    "gravityHopper": {
      "plugins": [],
      "type": "form"
    },
    "useCurrentUserAsAuthor": true,
    "postContentTemplateEnabled": false,
    "postTitleTemplateEnabled": false,
    "postTitleTemplate": "",
    "postContentTemplate": "",
    "lastPageButton": null,
    "pagination": null,
    "firstPageCssClass": null,
    "notifications": {
      "64ac2354c2f01": {
        "id": "64ac2354c2f01",
        "isActive": true,
        "to": "{admin_email}",
        "name": "Admin Notification",
        "event": "form_submission",
        "toType": "email",
        "subject": "New submission from {form_title}",
        "message": "{all_fields}"
      }
    },
    "confirmations": {
      "64ac2354c3409": {
        "id": "64ac2354c3409",
        "name": "Default Confirmation",
        "isDefault": true,
        "type": "message",
        "message": "Thanks for contacting us! We will get in touch with you shortly.",
        "url": "",
        "pageId": "",
        "queryString": ""
      }
    }
  }
}