Forms
How to use our form endpoints
The forms
part of the Delivery API provides endpoints to interact with the different forms available on a solution.
Both of the GET
endpoints generate a unique token that can be used in form submissions through the POST
endpoint. The generated token is saved in the cache for 60 minutes, and is returned in the response header:
x-form-token: 22b8e0be6fc54e61a49b24ba888e626b
Get all forms
GET /dwapi/forms
Retrieves a list of all available forms, and generates a unique token.
The response body is a list of Form
[
{
"id": 1,
"cssClass": "",
"name": "Contact",
"maxSubmits": 0,
"fields": [
{
"active": true,
"hideInReceipt": false,
"append": "",
"color": "",
"cssClass": "",
"description": "",
"groupId": 0,
"id": 1,
"image": "",
"maxLength": 0,
"name": "Name",
"placeholder": "Name",
"prepend": "",
"required": true,
"size": 0,
"sort": 1,
"systemName": "Name",
"text": "",
"textAreaHeight": 0,
"type": "TextInput",
"inputType": "text",
"htmlId": "Name",
"inputPattern": "",
"title": "",
"defaultValue": "",
"autoValue": "",
"isButton": false,
"isInput": true,
"isOther": false,
"isList": false,
"isTextArea": false
},
{
"active": true,
"hideInReceipt": false,
"append": "",
"color": "",
"cssClass": "",
"description": "",
"groupId": 0,
"id": 5,
"image": "",
"maxLength": 0,
"name": "Email",
"placeholder": "Email",
"prepend": "",
"required": true,
"size": 0,
"sort": 2,
"systemName": "Email",
"text": "",
"textAreaHeight": 0,
"type": "Email",
"inputType": "EMAIL",
"htmlId": "Email",
"inputPattern": "",
"title": "",
"defaultValue": "",
"autoValue": "",
"isButton": false,
"isInput": true,
"isOther": false,
"isList": false,
"isTextArea": false
},
{
"active": true,
"hideInReceipt": false,
"append": "",
"color": "",
"cssClass": "",
"description": "",
"groupId": 0,
"id": 2,
"image": "",
"maxLength": 0,
"name": "Phone",
"placeholder": "Phone",
"prepend": "",
"required": false,
"size": 0,
"sort": 3,
"systemName": "Phone",
"text": "",
"textAreaHeight": 0,
"type": "Tel",
"inputType": "TEL",
"htmlId": "Phone",
"inputPattern": "",
"title": "",
"defaultValue": "",
"autoValue": "",
"isButton": false,
"isInput": true,
"isOther": false,
"isList": false,
"isTextArea": false
},
{
"active": true,
"hideInReceipt": false,
"append": "",
"color": "",
"cssClass": "",
"description": "",
"groupId": 0,
"id": 3,
"image": "",
"maxLength": 0,
"name": "Message",
"placeholder": "Message",
"prepend": "",
"required": true,
"size": 0,
"sort": 4,
"systemName": "Message",
"text": "",
"textAreaHeight": 0,
"type": "Textarea",
"inputType": "TEXTAREA",
"htmlId": "Message",
"inputPattern": "",
"title": "",
"defaultValue": "",
"autoValue": "",
"isButton": false,
"isInput": true,
"isOther": false,
"isList": false,
"isTextArea": true
},
{
"active": true,
"hideInReceipt": false,
"append": "",
"color": "",
"cssClass": "",
"description": "",
"groupId": 0,
"id": 4,
"image": "",
"maxLength": 0,
"name": "Send",
"placeholder": "",
"prepend": "",
"required": false,
"size": 0,
"sort": 5,
"systemName": "Send",
"text": "",
"textAreaHeight": 0,
"type": "Submit",
"inputType": "SUBMIT",
"htmlId": "Send",
"inputPattern": "",
"title": "",
"defaultValue": "",
"autoValue": "",
"isButton": true,
"isInput": false,
"isOther": false,
"isList": false,
"isTextArea": false
}
]
},
{
"id": 2,
"cssClass": "",
"name": "Test",
"maxSubmits": 0,
"fields": [
{
"active": true,
"hideInReceipt": false,
"append": "",
"color": "",
"cssClass": "",
"description": "",
"groupId": 0,
"id": 1007,
"image": "",
"maxLength": 0,
"name": "Testing",
"placeholder": "",
"prepend": "",
"required": true,
"size": 0,
"sort": 1,
"systemName": "Test",
"text": "",
"textAreaHeight": 0,
"type": "TextInput",
"inputType": "text",
"htmlId": "Test",
"inputPattern": "",
"title": "",
"defaultValue": "",
"autoValue": "",
"isButton": false,
"isInput": true,
"isOther": false,
"isList": false,
"isTextArea": false
}
]
}
]
Get form by ID
GET /dwapi/forms/{formId}
Retrieves a specific form by its ID. As with the /forms
endpoint, this endpoint also generates a unique token for form submission.
The return of this endpoint is a single Form/forms
response.
Form submission
POST /dwapi/forms/{formId}
To submit a form, a unique token, generated by calling either of the GET
endpoints, is required. This must be included in the X-Form-Token header when submitting a form.
The form details to be submitted are added in the request body. The GET
endpoints show which fields
a form has, and these fields
can be added as formFieldValues
in the POST
request body.
If, for example, you wanted to submit a contact form, we can see from the GET
endpoint response above that the following details are available:
- ID: 1
- Fields available: Name, Email, Phone, Message, and Send
- Each of these fields have both a
name
and asystemName
, which can be used when setting values in the form submission
A request to submit a contact form with name and email fields could look like the following:
POST /dwapi/forms/1
Content-Type: application/json
X-Form-Token: 22b8e0be6fc54e61a49b24ba888e626b
{
"date": "2024-08-30T11:54:18.227Z",
"formFieldValues": [
{
"name": "Name",
"value": "JohnDoe",
"systemName": "Name"
},
{
"name": "Email",
"value": "test@dynamicweb.dk",
"systemName": "Email"
}
]
}
If the form has been submitted successfully, a 204 is returned.