Your server route
Keep your own form and post each submission to 1DB from your server. It’s one HTTP request, so it works from any framework or language, and 1DB answers with an error for each field that’s wrong.
- Any backend
- Per-field errors
- Duplicate-safe
How it works
- 1
Copy the key and form slug
Every website comes with an ingest key and a contact form. The site’s Integrate tab shows both, ready to paste into your environment.
- 2
Post the submission
Send the form’s fields as JSON with the key in X-API-Key. Add X-1DB-Contract: 2 to have every field checked.
- 3
Show what 1DB answers
A bad field comes back as a 400 that names it, with a message you can show next to the input. Anything else means the lead is stored.
curl https://gallant-goshawk-513.convex.site/v1/leads \
-H "Content-Type: application/json" \
-H "X-API-Key: 1db_YOUR_KEY" \
-H "X-1DB-Contract: 2" \
-d '{"formSlug":"contact","submission_id":"7f1c2a90-4b1e","email":"dana@northfieldsupply.com","message":"Need 48x40s"}'Good to know
- Pass the visitor on
- Send the visitor’s IP and browser in X-1DB-Client-IP and X-1DB-Client-UA. Without them, every lead looks like it came from your server.
- Retries are safe
- Send the same submission_id on every attempt at one submission and 1DB stores it once.
- The key can only send leads
- It can’t read, change or delete anything, so leaking it costs you junk leads at worst. Revoke it in the dashboard if that happens.
Guides
- GuideCapture leads
A Next.js contact form that saves every submission
Build a contact form in the Next.js App Router with a server action that stores each submission, shows per-field errors and survives double clicks.
- 3 min read
- Next.js
- Server actions
- GuideCapture leads
How to stop duplicate form submissions
Double clicks, slow networks and retries all send the same form twice. Give each submission an ID when the form loads and let the server drop the repeats.
- 3 min read
- Any framework
- Retries
- GuideCapture leads
A form backend for a static site
Three ways to take form submissions on a static HTML, Astro, Hugo or Eleventy site: a script tag, a fetch from the page, or a small serverless function.
- 3 min read
- Static HTML
- Astro
- Hugo
- Eleventy