Collecting form submissions

Is there a way to collect form submissions and store them in the DatoCMS model as records using REST API? Any examples, anywhere?

Hello @primoz.rome,

yes you can have a model that you use to store form submissions, for example, and have the form post to an endpoint that you control (lambda function maybe?) that parses the form, checks for spam, and sends a REST call to our endpoint.

I would advise against posting directly from your frontend as spammers could get your token and flood your CMS. Also remember to add a custom role restricted to creating form submissions, so you don’t risk messing up your content.

Let me know if you need more details.

2 Likes

Following up on what @mat_jack1 mentioned above. Here is the docco for Creating a new record. If you’re using something like Next.js you can set it up as an API Route (Or a Netlify function) and use the datocms-client package to insert the record. Definitely pass it off to a lambda function to keep things secret, and do all your validation before inserting anything.

2 Likes

We do not use AWS, but I guess these could be handled also with Netlify functions? Or did you mean some specific functionality available at AWS Lambda?

same stuff from the Netlify functions, yes!