Pour bien démarrer
Chaque adresse commence par https://awesomefor.ms/api/v1. Requêtes et réponses sont en JSON.
Authentifiez-vous avec un jeton d’accès personnel, créé dans les Paramètres, section « Assistants IA (MCP) », puis « Avancé : jeton d’accès personnel ». Un jeton personnel peut tout ce que peut votre compte. Une application qui agit pour d’autres utilisateurs passe plutôt par OAuth 2.0 (code d’autorisation avec PKCE), avec les seules portées qu’elle demande.
curl https://awesomefor.ms/api/v1/forms -H "Authorization: Bearer afm_…"
Jusqu’à 60 requêtes par minute et par jeton. Une erreur est un objet JSON avec un message « error » ; une erreur de validation détaille en plus ce qui ne va pas dans « errors ».
Le document OpenAPI 3.1 décrit les mêmes opérations pour les générateurs de code et les clients d’API. Pour un assistant IA, le serveur MCP est plus simple.
Les opérations ci-dessous sont décrites en anglais, comme dans le document OpenAPI.
OAuth
POST /api/v1/wordpress/clients
Register the OAuth client of a WordPress site.
The redirect URI must be on the site itself, over https (http only on localhost). Registering the same redirect URI again returns the same client.
| Paramètre | Où | Type | Description |
|---|---|---|---|
site_url (obligatoire) |
body | string |
|
redirect_uri (obligatoire) |
body | string |
201Created400Bad Request429Too many requests
Account
GET /api/v1/me
The connected account, its plan and the features the plan includes.
Portée OAuth : forms:read
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.429Too many requests
Forms
GET /api/v1/forms
Forms of every workspace of the account, most recently changed first.
Portée OAuth : forms:read
| Paramètre | Où | Type | Description |
|---|---|---|---|
workspace |
query | string |
Id of a workspace, from `/me`: only its forms are listed. |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Not Found429Too many requests
POST /api/v1/forms
Create a draft form with at least one page.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
Idempotency-Key |
header | string |
Any unique string, kept 24 hours: a retry with the same key and body returns the form the first call created, with an `Idempotent-Replayed: true` header, instead of a duplicate. |
title (obligatoire) |
body | string |
At most 255 characters. |
description |
body | string | null |
|
pages (obligatoire) |
body | array of object |
The pages of the form, in order. |
quiz |
body | object |
Quiz settings to change, the keys left out keep their value: "enabled", "show_score" and "show_answers" (true or false), "outcomes" (at most 10 ranges {"min", "max", "label", "message"}; the first range holding the score gives the level of the response, its "label", and replaces the confirmation message; a bound left out means no limit). |
workspace |
body | string |
Id of the workspace to create the form in, from `/me`. Defaults to the personal workspace. |
201Created401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Not Found409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/forms/generate
Create a draft form from a description, written by AI.
The answer comes once the form is written, usually within seconds. Each call counts toward the AI generations of the plan, like in the editor, and the editor limits apply: 5 a minute, and a daily fair use on paid plans. A refused description counts too.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
Idempotency-Key |
header | string |
Same as for createForm: a retry with the same key neither generates nor counts again. |
prompt (obligatoire) |
body | string |
What the form is for and the questions to ask, 10 to 2000 characters. |
layout |
body | "auto" | "single" | "multi" |
One page, several pages, or let the AI choose. |
logic |
body | boolean |
Let the AI show or hide questions depending on earlier answers. |
workspace |
body | string |
Id of the workspace to create the form in, from `/me`. Defaults to the personal workspace. |
201Created401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Not Found409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too Many Requests503The AI service is busy or did not answer in time: retry in a moment.
GET /api/v1/forms/{form}
A form with its pages and fields.
Portée OAuth : forms:read
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
DELETE /api/v1/forms/{form}
Move a form to the trash: it goes offline at once.
Like in the app, the form stays 30 days in the trash, where only the app can restore it, then it is erased for good with its responses and files.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
204No content401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
PUT /api/v1/forms/{form}
Replace the pages and fields of a form, and optionally its title and description.
Send back every page and field you keep with its id: anything left out is deleted. On a published form the changes stay pending, and respondents keep the published version, until publishForm or discardFormChanges.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
title |
body | string |
At most 255 characters; kept as is when left out. |
description |
body | string | null |
Kept as is when left out. |
pages (obligatoire) |
body | array of object |
The complete list of pages, in order. Pages and fields left out are deleted. |
quiz |
body | object |
Quiz settings to change, the keys left out keep their value: "enabled", "show_score" and "show_answers" (true or false), "outcomes" (at most 10 ranges {"min", "max", "label", "message"}; the first range holding the score gives the level of the response, its "label", and replaces the confirmation message; a bound left out means no limit). |
languages |
body | object |
Languages to change, the keys left out keep their value: "primary" (fr, en, nl, de, es or it, or null for the language of the owner account), "additional" (the other languages the form is offered in), "translations" (the translations of the form texts, which replace the current ones: {"nl": {"title", "description", "confirmation_message", "submit_label", "quiz_outcomes": {"0": "message of the first score range"}}}). Pages and fields carry their own "translations" in the same shape. |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.422The request was refused; `errors` lists every problem.429Too many requests
PATCH /api/v1/forms/{form}
Change some pages or fields of a form without sending back its whole structure.
The operations apply in order to the structure of getForm; if one is invalid, none is saved. On a published form the changes stay pending, like updateForm.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
title |
body | string |
At most 255 characters; kept as is when left out. |
description |
body | string | null |
Kept as is when left out. |
operations (obligatoire) |
body | array of object |
At most 100 operations, each an object with "op" set to one of add_field, update_field, remove_field, move_field, add_page, update_page, remove_page, move_page. "position" counts from 0 and defaults to the end; "page_id" defaults to the last page. Empty to change only the title, the description, the quiz or the language settings. |
quiz |
body | object |
Quiz settings to change, the keys left out keep their value: "enabled", "show_score" and "show_answers" (true or false), "outcomes" (at most 10 ranges {"min", "max", "label", "message"}; the first range holding the score gives the level of the response, its "label", and replaces the confirmation message; a bound left out means no limit). |
languages |
body | object |
Languages to change, the keys left out keep their value: "primary" (fr, en, nl, de, es or it, or null for the language of the owner account), "additional" (the other languages the form is offered in), "translations" (the translations of the form texts, which replace the current ones: {"nl": {"title", "description", "confirmation_message", "submit_label", "quiz_outcomes": {"0": "message of the first score range"}}}). Pages and fields carry their own "translations" in the same shape. |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/forms/{form}/duplicate
Create a draft copy of a form, without its responses.
The copy gets the pages, fields and settings the author works on, pending changes included, in the workspace of the form.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
Idempotency-Key |
header | string |
Same as for createForm. |
title |
body | string |
At most 255 characters. Defaults to the title of the form followed by "(copy)". |
201Created401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/forms/{form}/publish
Publish a form, or put the pending changes of a published form online.
Recent or unverified accounts publish from the editor instead.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/forms/{form}/unpublish
Take a form offline; its responses and pending changes are kept.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/forms/{form}/discard-changes
Drop the pending changes of a published form; it goes back to its published version.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
GET /api/v1/forms/{form}/responses
Responses newest first, with the columns of the CSV export.
Portée OAuth : responses:read
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
page |
query | integer |
|
per_page |
query | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.422The request was refused; `errors` lists every problem.429Too many requests
GET /api/v1/forms/{form}/responses/{response}
A response, with the columns of the CSV export and its uploaded files.
Portée OAuth : responses:read
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
response (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
DELETE /api/v1/forms/{form}/responses/{response}
Move a response to the trash and free its booked time slot.
Like in the app, the response stays 30 days in the trash, where only the app can restore it, then it is erased for good with its files.
Portée OAuth : responses:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
response (obligatoire) |
path | integer |
|
delete_calendar_event |
query | boolean |
Also delete from the connected calendar the event of the time slot booked with the response. |
200401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
GET /api/v1/forms/{form}/responses/{response}/files/{file}
Download a file uploaded with a response.
`file` is the index of the file in the `files` of getResponse.
Portée OAuth : responses:read
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
response (obligatoire) |
path | integer |
|
file (obligatoire) |
path | integer |
200401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
Templates
GET /api/v1/templates
The ready-made forms, to create a form from with createFormFromTemplate.
Portée OAuth : forms:read
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.429Too many requests
POST /api/v1/templates/forms
Create a draft form from a template.
The form gets the pages and fields of the template; change them with editForm, then publish it with publishForm.
Portée OAuth : forms:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
Idempotency-Key |
header | string |
Same as for createForm. |
template (obligatoire) |
body | string |
Key of the template, from listTemplates. |
title |
body | string |
At most 255 characters. Defaults to the title of the template. |
workspace |
body | string |
Id of the workspace to create the form in, from `/me`. Defaults to the personal workspace. |
201Created401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Not Found409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
Webhooks
GET /api/v1/forms/{form}/webhooks
The webhooks of a form, oldest first.
Portée OAuth : webhooks:read
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
POST /api/v1/forms/{form}/webhooks
Send every new response of a form to a URL; the answer holds its signing secret.
Each new response to the form is then sent once, as a JSON POST to the URL, with `form_id`, `response_id`, `submitted_at` (ISO 8601) and `data`, the answers keyed by the `name` of each field of getForm; when the response has files, `files` lists temporary download links valid 7 days, keyed like `data`. The request times out after 10 seconds, does not follow redirects and is not sent again after a failure. Each request carries an `X-AwesomeForms-Signature: t=<unix time>,v1=<hex>` header: `v1` is the HMAC-SHA256, keyed with the `secret` of the webhook, of the time, a dot and the raw body. Recompute it on reception, compare it in constant time and refuse a time more than 5 minutes away from yours. The `secret` is returned only by createWebhook and rotateWebhookSecret.
Portée OAuth : webhooks:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
Idempotency-Key |
header | string |
Any unique string, kept 24 hours: a retry with the same key and body returns the webhook the first call created, with an `Idempotent-Replayed: true` header, instead of a duplicate. |
url (obligatoire) |
body | string |
An HTTPS address that resolves to public IP addresses only. |
enabled |
body | boolean |
A disabled webhook sends nothing until enabled again. |
201Created401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
PATCH /api/v1/forms/{form}/webhooks/{webhook}
Change the URL of a webhook, or enable or disable it.
Refused when the plan of the workspace no longer includes webhooks; deleting them stays possible.
Portée OAuth : webhooks:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
webhook (obligatoire) |
path | integer |
|
url |
body | string |
An HTTPS address that resolves to public IP addresses only; kept as is when left out. |
enabled |
body | boolean |
Kept as is when left out. |
200OK401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.422The request was refused; `errors` lists every problem.429Too many requests
DELETE /api/v1/forms/{form}/webhooks/{webhook}
Delete a webhook; responses are no longer sent to its URL.
Portée OAuth : webhooks:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
webhook (obligatoire) |
path | integer |
204No content401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
POST /api/v1/forms/{form}/webhooks/{webhook}/rotate-secret
Replace the signing secret of a webhook and return the new one.
The previous secret stops working at once: requests sent from then on are signed with the new one.
Portée OAuth : webhooks:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
form (obligatoire) |
path | integer |
|
webhook (obligatoire) |
path | integer |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
Imports
POST /api/v1/imports
Start an import from another tool.
Nothing is ever changed at the source.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
Idempotency-Key |
header | string |
Any unique string, kept 24 hours: a retry with the same key and body returns the import the first call started, with an `Idempotent-Replayed: true` header, instead of a second one. |
source (obligatoire) |
body | ImportSource |
|
label |
body | string |
Where the data comes from, for the report (a site, a file name). |
workspace |
body | string |
Id of the workspace the forms are created in, from `/me`. Defaults to the personal workspace. |
201Created401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Not Found409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/imports/wordpress
Offer a WordPress site to AwesomeFor.ms, which then reads the forms the site chose.
The key is read once, kept encrypted and destroyed when the import is validated or cancelled. The answer gives the page where the user confirms the import. With `import`, an open import reads the site again with the new key instead.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
source (obligatoire) |
body | ImportSource |
|
rest_url (obligatoire) |
body | string |
REST address of the plugin on the site, which is reached over https. |
key (obligatoire) |
body | string |
Secret that gives read access to the forms chosen on the site. |
forms (obligatoire) |
body | array of string |
Ids of the forms the site gives. |
label |
body | string |
Name of the site, for the report. |
import |
body | string |
Id of an open import to read again. |
workspace |
body | string |
Id of the workspace the forms go to, from `/me`; the user can still change it when confirming. Defaults to the personal workspace. |
200OK201Created401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Not Found422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/imports/{import}/wordpress/revoke
The site withdrew its access: stop reading it, keeping what was imported.
The import stays open: it can still be validated or cancelled.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
GET /api/v1/imports/{import}
An import and its reconciliation: for every form, the counts given by the source against what was imported.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.429Too many requests
POST /api/v1/imports/{import}/forms
Create the form for a source form, or, when its source_ref was already imported, keep the existing form and only refresh the expected counts and notes.
Returns the field names to key the responses with.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
|
source_ref (obligatoire) |
body | string |
Stable identifier of the form at the source, unique within the account for this source (for example site and form id). |
title (obligatoire) |
body | string |
At most 255 characters. |
description |
body | string | null |
|
pages (obligatoire) |
body | array of object |
Give every field a name: responses are keyed by it. A source field with no equivalent becomes a hidden field, so its values are kept. |
expected (obligatoire) |
body | object |
What the source holds, to reconcile against. |
notes |
body | object |
For the readable report. |
200OK201Created401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/imports/{import}/forms/{form}/responses
Add up to 100 responses.
A response whose source_ref is already imported is skipped, so sending a batch again is safe. Imported responses send no alert and do not count toward the monthly response quota. The whole batch is refused if one response is invalid.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
|
form (obligatoire) |
path | integer |
|
responses (obligatoire) |
body | array of object |
200OK401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/imports/{import}/forms/{form}/files
Attach one file to an imported response (multipart/form-data).
It is stored only if its SHA-256 matches. A photo or a PDF is then recompressed when that makes it lighter, except a signed PDF: the storage quota counts the stored size, while size and sha256 in the answer stay those of the file sent. A file the source lists but cannot provide is declared with missing=1 and shows in the report. Sending the same source_ref again returns the stored file. A file stored elsewhere can be given by its public url instead of its content: it is fetched in the background, shows as pending until then, and the import cannot be validated meanwhile. A big file can be sent in parts, each with its offset in the file and the total size: a part must start where the previous one ended (409 with the bytes received otherwise), an offset of 0 starts over, and the last part checks size and sha256 before the file is stored like any other.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
|
form (obligatoire) |
path | integer |
200OK201Created202Accepted401Missing, unknown or revoked access token.402The plan quota is exhausted.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.422The request was refused; `errors` lists every problem.429Too many requests
POST /api/v1/imports/{import}/cancel
Delete everything the import brought in: the forms it created, and the responses and files it added.
Only while the import is in progress.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.429Too many requests
POST /api/v1/imports/{import}/validate
Close the import once every count matches the source.
It can no longer be cancelled.
Portée OAuth : imports:write
| Paramètre | Où | Type | Description |
|---|---|---|---|
import (obligatoire) |
path | string |
200OK401Missing, unknown or revoked access token.403The token lacks the scope, or the account is refused.404Unknown resource, or one that belongs to another account.409The import is closed or its counts do not match the source yet, or the idempotency key is in use or was sent with another body.429Too many requests
Contenu envoyé par un webhook
Un webhook, créé avec createWebhook ou dans l’éditeur de formulaire, envoie chaque nouvelle réponse une fois, en requête POST JSON :
{
"form_id": 42,
"response_id": 1337,
"submitted_at": "2026-12-01T09:30:00+00:00",
"data": {
"full_name": "Ada Lovelace",
"email": "ada@example.org"
},
"files": {
"resume": [
"https://awesomefor.ms/files/form-uploads/…/resume.pdf?expires=…&signature=…"
]
},
"score": 42,
"score_level": "Hot"
}
« data » contient les réponses, indexées par le nom de chaque champ tel que getForm le renvoie. « files » n’est présent que si la réponse a des fichiers : des liens de téléchargement temporaires, valables 7 jours. La requête expire après 10 secondes, ne suit pas les redirections et n’est pas renvoyée après un échec.
« score » et « score_level » ne sont présents que si le formulaire note ses réponses : le score, et le nom du niveau de la première plage qui le contient, null s’il n’en a pas.
Vérifier la signature
Chaque webhook a un secret de signature, affiché une fois à sa création, puis seulement quand vous le remplacez. Chaque requête porte un en-tête X-AwesomeForms-Signature composé de l’heure d’envoi (t, en secondes Unix) et de v1, le HMAC-SHA256 de cette heure, d’un point et du corps brut, avec ce secret pour clé.
À la réception, calculez le même HMAC à partir du corps brut, avant tout décodage JSON, comparez-le en temps constant et refusez une heure à plus de 5 minutes de votre horloge, pour qu’une requête interceptée ne puisse pas être rejouée.
// PHP
$body = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_AWESOMEFORMS_SIGNATURE'] ?? ''), $sig);
$expected = hash_hmac('sha256', ($sig['t'] ?? '').'.'.$body, $secret);
$valid = hash_equals($expected, $sig['v1'] ?? '') && abs(time() - (int) ($sig['t'] ?? 0)) <= 300;
// Node.js, with the raw body as a Buffer (express.raw({ type: 'application/json' }))
const crypto = require('node:crypto');
const sig = Object.fromEntries(req.get('X-AwesomeForms-Signature').split(',').map((p) => p.split('=')));
const expected = crypto.createHmac('sha256', secret).update(`${sig.t}.${req.body}`).digest('hex');
const given = Buffer.from(sig.v1 ?? '');
const valid = given.length === expected.length && crypto.timingSafeEqual(Buffer.from(expected), given)
&& Math.abs(Date.now() / 1000 - Number(sig.t)) <= 300;