Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

This module provides API endpoints to integrate Drupal's Webform module with headless applications. It allows retrieving form structures in specific schema formats, like FormKit, and submitting form data.

Webform Headless integrates Webform with headless frontends by providing API endpoints for managing submissions and getting forms in structured schema formats. Currently, only the FormKit schema is supported, but contributions for other schema formats are welcome.

Requirements

This module requires the following modules:

Installation

Install as you would normally install a contributed Drupal module. For further information, see Installing Drupal Modules.

Configuration

Enable the module at Administration > Extend.

Usage

Fetching the schema

GET https://{{host}}/webform/{{webformId}}/json/schema?schema={{schemaId}}
Accept: application/json
  • webformId should be the machine name of the webform.
  • schemaId should be the machine name of the schema. Currently, only form_kit is supported.

The response contains a JSON object with two keys:

  • schema contains the schema definition.
  • values contains the default values for the form.
{
  "schema": [
    {
      "$cmp": "FormKit",
      "props": {
        "type": "form",
        "id": "contact",
        "method": "POST"
      },
      "children": [
        {
          "name": "first_name",
          "id": "contact--first_name",
          "key": "contact--first_name",
          "label": "First name",
          "$formkit": "text",
          "validation": [
            [
              "required"
            ]
          ],
          "classes": {
            "outer": "formkit-outer--first_name"
          },
          "elementType": "textfield"
        },
        {
          "name": "last_name",
          "id": "contact--last_name",
          "key": "contact--last_name",
          "label": "Last name",
          "$formkit": "text",
          "validation": [
            [
              "required"
            ]
          ],
          "classes": {
            "outer": "formkit-outer--last_name"
          },
          "elementType": "textfield"
        },
        {
          "name": "email",
          "id": "contact--email",
          "key": "contact--email",
          "label": "Email",
          "$formkit": "email",
          "validation": [
            [
              "email"
            ]
          ],
          "classes": {
            "outer": "formkit-outer--email"
          },
          "elementType": "email"
        },
        {
          "name": "birth_date",
          "id": "contact--birth_date",
          "key": "contact--birth_date",
          "label": "Birth date",
          "$formkit": "datepicker",
          "value-format": "YYYY-MM-DD",
          "format": "DD\/MM\/YYYY",
          "value-locale": "nl",
          "week-start": "1",
          "max-date": "2008-11-15",
          "placeholder": "DD\/MM\/YYYY",
          "classes": {
            "outer": "formkit-outer--birth_date"
          },
          "elementType": "date"
        }
      ]
    }
  ],
  "values": {
    "campaign_id": "1535"
  }
}

Creating submissions

POST https://{{host}}/webform/{{webformId}}/json/submission?schema={{schemaId}}
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Referer: https://{{host}}/some-page

[email protected]&first_name=John&last_name=Harrison
  • webformId should be the machine name of the webform.
  • schemaId should be the machine name of the schema. Currently, only formkit is supported.
  • The Referer header is used for the 'Submitted to' field of the submission.

The request has the same structure as normal webform POSTs. You can find an example by inspecting a form submission on the webform test page.

The response contains either an array of error messages:

{
  "errors": [
    {
      "message": "Birth date is a required field.",
      "path": [
        "birth_date"
      ]
    }
  ]
}

or the submission UUID, values and the confirmation settings:

{
  "uuid": "56201a2f-d19f-4fde-9398-2442c19fee0f",
  "data": {
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Harrison"
  },
  "confirmation": {
    "type": "url",
    "title": null,
    "url": "\/bedankt?petitionId=[webform_submission:values:uuid]",
    "excludeQuery": null,
    "excludeToken": null,
    "update": null
  }
}

Uploading files

POST https://{{host}}/webform/{{webformId}}/json/upload
Accept: application/json
Content-Type: application/x-www-form-urlencoded

files[{{elementName}}][]={{file}}
  • webformId should be the machine name of the webform.
  • elementName should be the name of the file upload element in the webform.
  • file should be the file data to upload

The response contains either an array of error messages:

{
  "errors": [
    {
      "message": "File could not be saved"
    }
  ]
}
}

or the file IDs of the uploaded files, keyed by the element name

{
  "{{elementName}}": [
    "{{fileId}}"
  ]
}

These file IDs can be used in the submission creation request to associate
the uploaded files with the submission.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Jan 2025
Latest release
6 months ago
Releases (12 mo)
2 ▲ from 1
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.0.0-alpha3 Pre-release 10–11 Feb 9, 2026
1.0.0-alpha2 Pre-release 10–11 Oct 27, 2025
1.0.0-alpha1 Pre-release 10–11 Jan 17, 2025