Forminal

Webhook

Invia ogni nuovo invio a un URL a tua scelta come richiesta firmata, e ritenta quando il tuo endpoint non è disponibile.

I webhook inviano ogni nuovo invio a un URL a tua scelta, come richiesta firmata. Scegli tu il metodo, il formato e quali campi includere nel corpo. Usali quando le risposte devono raggiungere il tuo server, uno strumento interno o qualsiasi servizio che accetta richieste HTTPS, senza passare per Make o Zapier.

Esempi

  • Creazione di un account nella tua app per ogni persona che si iscrive tramite un modulo di registrazione.
  • Invio di ogni richiesta di supporto a un servizio interno che apre un ticket.
  • Invio degli ordini da un modulo di pagamento a un sistema di evasione una volta che il pagamento è stato effettuato.
  • Chiamata a un'API che si aspetta una PUT con campi codificati in formato, come email e source, invece del nostro documento JSON completo.

Configuralo

  1. Open the form in the builder, select Integrations in the top bar, then select Connect next to Webhooks.
La scheda Integrazioni di un modulo che elenca Google Sheets, Make, Zapier e Webhook, ognuno con un pulsante Connetti o GestisciLa scheda Integrazioni di un modulo che elenca Google Sheets, Make, Zapier e Webhook, ognuno con un pulsante Connetti o Gestisci
Webhook nella scheda Integrazioni
  1. Under Add a Webhook, paste your URL. It has to start with https://.
  2. Give it a Name if you like. Leave it empty and the webhook is named after the URL’s host.
  3. Under Method, choose GET, POST, PUT, PATCH or DELETE. POST is selected to start with.
  4. Under Format, choose JSON or Form. GET has no format: it sends the body as a query string, so it needs at least one body field.
  5. If your endpoint expects a key or a token, select Add Header and enter the header’s name and value, such as Authorization and Bearer followed by your token.
  6. Under Request Body, leave the list empty to send the full submission, or select Add Field for each field your endpoint expects: enter its key, then a value. Type @ in the value to insert an answer, and mix it with fixed text if you like.
Il modulo Aggiungi un webhook con un URL endpoint, il nome Helpdesk, POST e JSON selezionati, un'intestazione di autorizzazione e due campi corpo, uno dei quali è la risposta EmailIl modulo Aggiungi un webhook con un URL endpoint, il nome Helpdesk, POST e JSON selezionati, un'intestazione di autorizzazione e due campi corpo, uno dei quali è la risposta Email
Un webhook con un'intestazione e due campi nel corpo
  1. Leave Export Existing Submissions off until your endpoint works. You can export from the webhook’s row later.
  2. Select Save Changes, then Send Test Data on its row to check that your endpoint receives a request.
L'elenco Webhook connessi con il webhook Helpdesk, il suo interruttore, un pulsante Invia dati di test, un pulsante di esportazione e un cestinoL'elenco Webhook connessi con il webhook Helpdesk, il suo interruttore, un pulsante Invia dati di test, un pulsante di esportazione e un cestino
Il webhook salvato sotto Webhook collegati

The webhook then appears under Connected Webhooks. Each row has a switch to pause it, Send Test Data, a pencil to rename it, the export button (the upload arrow) to export existing submissions, a link to its own page, and a bin to delete it. On its page you can change the URL, method, format, headers and body, export existing submissions, find the signing secret, and see recent deliveries.

Cosa riceve il tuo endpoint

Each submission arrives as one request, with the method you chose. With an empty Request Body, the body is the full submission, the same document the Make and Zapier integrations get:

  • event: sempre submission.created, e test: true per dati di test, false altrimenti.
  • form: l'ID e il titolo del modulo.
  • submission: il suo ID, quando è stato inviato, la pagina di origine, il browser, il tempo impiegato in secondi, il Paese del rispondente come codice e nome (o null quando è sconosciuto), i suoi valori UTM sotto utm quando il link ne trasportava, i suoi tag e il suo pagamento quando il modulo accetta pagamenti.
  • answers: ogni risposta come testo, indicizzata per etichetta della domanda. Due domande con la stessa etichetta diventano "Email" e "Email (2)".
  • answersById: lo stesso testo indicizzato per l'ID di ogni campo, che rimane lo stesso quando rinomini una domanda.
  • fields: un elenco con l'ID di ogni campo, tipo, etichetta, la risposta come testo e il suo valore grezzo.

Le risposte vengono lette nel modo in cui appaiono nella tabella delle sottomissioni, e i caricamenti di file e le firme arrivano come link ai file, nel tuo Google Drive o nella tua libreria multimediale. Un link alla libreria multimediale si apre solo per chi ha effettuato l'accesso con accesso alle sottomissioni del modulo, o con una chiave API. Tutte le intestazioni che hai aggiunto vengono inviate con ogni richiesta.

I tuoi campi nel corpo

When you add body fields, the body holds only those keys, each with its value. An inserted answer reads the same as in the full submission, so a file upload gives its links. When a question was left unanswered, the value uses the Default Value you set by selecting the inserted answer, or stays empty.

Formati

  • JSON invia application/json.
  • Form invia application/x-www-form-urlencoded. La sottomissione completa viene appiattita con parentesi, come form[title], answers[Email] e fields[0][id], nel modo in cui PHP e la maggior parte dei framework la leggono.
  • GET inserisce la stessa codifica del modulo nella stringa di query e non invia alcun corpo, dopo qualsiasi query che l'URL ha già.

Verifica la firma

Ogni richiesta viene firmata seguendo la specifica Standard Webhooks, in modo che il tuo endpoint possa dire che proviene da noi e non è stata modificata durante il transito. Tre intestazioni trasportano la firma: webhook-id nomina la consegna e rimane la stessa quando viene ritentata, webhook-timestamp indica quando è stato inviato questo tentativo e webhook-signature è v1, seguito da un HMAC-SHA256 dell'ID, del timestamp e del corpo, uniti da punti. Per una richiesta GET, l'intera stringa di query con cui è stata inviata, senza il ?, prende il posto del corpo.

Find the secret on the webhook’s page under Signing Secret and select Reveal. The Standard Webhooks libraries check it for you. In Node.js, with the raw request body and the secret:

import { Webhook } from 'standardwebhooks'
const payload = new Webhook(process.env.WEBHOOK_SECRET).verify(rawBody, req.headers)

verify throws when the signature doesn’t match or the timestamp is more than five minutes old. Use webhook-id to ignore a delivery you’ve already handled. Select Rotate to replace the secret; the old one stops working at once, so update your endpoint right after.

La sezione Segreto di Firma di una pagina webhook con il segreto nascosto e i pulsanti Mostra e RuotaLa sezione Segreto di Firma di una pagina webhook con il segreto nascosto e i pulsanti Mostra e Ruota
Il segreto di firma nella pagina del webhook

Consegne e ritentativi

La richiesta viene inviata subito dopo ogni sottomissione, una volta per sottomissione. Su un modulo con un campo Pagamento, attende che il pagamento venga effettuato. Lo spam non viene mai inviato. Qualsiasi risposta 2xx viene conteggiata come consegnata. I reindirizzamenti non vengono seguiti, quindi una risposta 3xx viene conteggiata come un fallimento.

Se il tuo endpoint non risponde entro 10 secondi, non è raggiungibile o risponde con un errore, la consegna viene ritentata dopo 1 minuto, poi 5 e 30 minuti, poi 2, 5 e 10 ore: sette tentativi in circa 18 ore. Un ritentativo va all'URL e alle intestazioni che il webhook ha in quel momento, quindi correggere un URL errato corregge anche le consegne in attesa. Mantiene il metodo, il formato e il corpo con cui è stato inviato originariamente. Una risposta 410 Gone interrompe immediatamente i ritentativi. La pausa del webhook li interrompe anche.

Recent Deliveries on the webhook’s page lists the newest 50, each as Delivered, Retrying or Failed, with the last answer’s status code and the number of attempts. Select Show Body to see exactly what was sent, and Resend to send it again now, under the same webhook-id.

Consegne Recenti con tre righe Consegnate e una riga In Tentativo di Riprova che ha risposto 503, ognuna con Mostra Corpo e ReinviaConsegne Recenti con tre righe Consegnate e una riga In Tentativo di Riprova che ha risposto 503, ognuna con Mostra Corpo e Reinvia
Consegne recenti nella pagina del webhook

Invia le submission che hai già

A webhook gets the submissions that come in after you add it. To send the ones the form already has, select the export button on the webhook’s row and then Export, or turn on Export Existing Submissions on the webhook’s page and select Save Changes. The dialog and the note under the switch say how many submissions it will send.

Each one goes as its own signed request, oldest first, in the background after new submissions and at most 50 a minute, and shows in Recent Deliveries. It sends what a live delivery would have: complete submissions that aren’t spam, and a submission with a payment only once it’s paid. The row shows the progress on one line, such as “Exporting · 120 of 400 sent · Stop export”. Select Stop export to drop the requests still waiting. Running it again sends everything again under new webhook-ids, so check the submission ID if your endpoint must not handle one twice. It won’t start while the webhook is off or while it’s already exporting.

Buono a sapersi

  • Un modulo può inviare fino a 10 webhook e ciascun webhook può avere fino a 10 intestazioni e 50 campi nel corpo.
  • L'URL deve usare https, essere lunga al massimo 2000 caratteri e puntare a un indirizzo pubblico. Vengono rifiutati indirizzi su reti private, localhost e nomi senza punto, così come nome utente e password all'interno dell'URL: metti le credenziali in un header.
  • I nomi degli header usano lettere, cifre e trattini. Content-Type, User-Agent e i tre header webhook- sono impostati per te, e gli header di connessione come Connection o Upgrade non possono essere impostati. Un valore rimane su una riga e usa caratteri normali.
  • Una chiave del corpo è lunga da 1 a 100 caratteri su una riga, e ogni chiave appare una sola volta. Le chiavi sono sensibili alle maiuscole, quindi Email ed email sono due chiavi diverse. Un valore può essere lungo fino a 2000 caratteri.
  • Per GET, l'URL con la sua query deve rimanere entro 2000 caratteri. Uno più lungo non viene inviato né ritentato, quindi invia meno campi nel corpo o campi più corti.
  • I campi del corpo non ottengono la crittografia aggiuntiva degli header, e vengono mostrati nella pagina del webhook. Metti le chiavi API e i token in un header.
  • I valori degli header sono memorizzati crittografati e non vengono mai più mostrati. Quando modifichi un webhook, un header che lasci vuoto mantiene il suo valore salvato.
  • I dati di test hanno test impostato su true e risposte di esempio, il suo webhook-id inizia con msg_test_ e non viene conservato nel log delle consegne. Invio Dati di Test e Reinvia condividono un limite di 20 al minuto.
  • Le consegne rimangono nel log per 30 giorni. L'eliminazione di un webhook elimina il suo log e tutte le consegne ancora in attesa di ritentare.

Domande frequenti

Un webhook può inviare a localhost o a un indirizzo http?

No. L'URL deve usare https e puntare a un indirizzo pubblico. Vengono rifiutati localhost, indirizzi su reti private e nomi senza punto.

Quante volte viene ritentata una richiesta webhook fallita?

Sette tentativi in circa 18 ore, a partire da 1 minuto dopo il primo fallimento. Una risposta 410 Gone interrompe immediatamente i ritentativi, così come la pausa del webhook.

Come posso verificare che una richiesta webhook provenga da Forminal?

Ogni richiesta è firmata secondo la specifica Standard Webhooks, con una firma HMAC-SHA256 nell'header webhook-signature. Verificala con una libreria Standard Webhooks e il segreto di firma dalla pagina del webhook.

Quanti webhook può avere un modulo?

Un modulo può inviare fino a 10 webhook e ciascun webhook può avere fino a 10 intestazioni e 50 campi nel corpo.

Dove dovrei inserire una chiave API per il mio endpoint?

Inseriscila in un header. I valori degli header sono memorizzati crittografati e non vengono mai più mostrati, mentre i campi del corpo non ottengono quella crittografia aggiuntiva e vengono mostrati nella pagina del webhook.

I webhook richiedono un piano a pagamento?

I webhook funzionano su ogni piano.

Posso inviare le submission arrivate prima che aggiungessi il webhook?

Sì. Seleziona il pulsante di esportazione sulla riga del webhook, quindi Esporta. Ogni submission passata viene inviata come richiesta firmata separata, dalla più vecchia, e eseguirlo di nuovo le invia tutte di nuovo.

Come impostarlo →

Il tuo primo modulo è gratuito, e così è il centesimo

Nessuna registrazione per iniziare. Hai già un account? Accedi.