Tutorials

Building a Form Backend API in Minutes

1DB Team·
blog/form-backend-api

Building a form backend from scratch means setting up a server, database, validation, rate limiting, and error handling. Or you can use 1DB's API and skip all of that.

What you get out of the box

With 1DB as your form backend:

  • REST API — Simple POST endpoint for form submissions
  • Validation — Schema-based validation with clear error messages
  • Storage — Persistent storage with full query capabilities
  • CRM sync — Automatic sync to HubSpot or Salesforce
  • Webhooks — Real-time notifications on new submissions
  • Rate limiting — Built-in protection against abuse
  • Type safety — Full TypeScript types for request and response

Quick start

1. Create a project

Sign up at 1-db.com and create a project. You'll get a project ID and API key.

2. Submit a form

Send a POST request with your form data:

curl -X POST https://api.1db.co/v2/records \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Alex Chen",
    "email": "alex@startup.io",
    "company": "StartupCo",
    "message": "Interested in enterprise plan"
  }'

3. Query your data

curl https://api.1db.co/v2/records?source=contact-form \
  -H "Authorization: Bearer your-api-key"

That's it. Three steps to a production form backend.

TypeScript SDK

For TypeScript projects, the SDK provides type-safe access:

import { OneDB } from "@1db/sdk";

const db = new OneDB({ apiKey: "your-api-key" });

// Create a record
const lead = await db.records.create({
  name: "Alex Chen",
  email: "alex@startup.io",
  source: "contact-form",
});

// Query records
const results = await db.records.list({
  filter: { source: "contact-form" },
  sort: { field: "createdAt", order: "desc" },
  limit: 25,
});

Client-side form handling

Connect a form directly from the browser:

document.querySelector("form").addEventListener("submit", async (e) => {
  e.preventDefault();
  const data = Object.fromEntries(new FormData(e.target));

  const response = await fetch("https://api.1db.co/v2/records", {
    method: "POST",
    headers: {
      "Authorization": "Bearer your-public-key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify(data),
  });

  if (response.ok) {
    window.location.href = "/thank-you";
  }
});

Webhooks

Get notified instantly when a form is submitted:

{
  "event": "record.created",
  "data": {
    "id": "rec_7x9k2mN4",
    "name": "Alex Chen",
    "email": "alex@startup.io",
    "source": "contact-form",
    "createdAt": "2026-02-25T10:30:00Z"
  }
}

Configure webhook URLs in your project settings. 1DB retries failed deliveries automatically.

When to use a form backend API

A form backend API is the right choice when:

  • You want full control over your form UI and UX
  • You're building with a frontend framework (React, Vue, Svelte)
  • You need server-side validation and processing
  • You want to avoid managing a backend server

Get started with 1DB — free for up to 1,000 leads per month.

EOF1DB Team