Getting started

Quickstart

Send leads from your website to 1DB in three steps.

Using Claude Code or another agent?

Run npx @1db/cli setup once in your terminal, then ask your agent to “set up 1DB for acme.com”. It adds the website and writes DB_API_ENDPOINT, DB_API_KEY and DB_FORM_SLUG, the same variables this guide uses. See AI agents, MCP and CLI.

Prerequisites

1

Create a website and form

First, create a website in your dashboard, then a form for the data you want to collect. Every website posts to the same endpoint; its key and the form's slug tell 1DB where a lead belongs.

  1. 1.Go to Websites and click "New Website"
  2. 2.Enter a name and optional domain
  3. 3.Click "Create Form" and choose a template or start from scratch
  4. 4.Configure your form fields and save
2

Get the key and form slug

Each website gets an ingest key when it is created. The website's page in the dashboard shows it with the form's slug. Put them in the project's env file:

.env.local
DB_API_ENDPOINT=https://gallant-goshawk-513.convex.site
DB_API_KEY=1db_...        # 1db_ followed by 32 hex characters
DB_FORM_SLUG=acme-contact # your form's real slug

Where the key goes

The ingest key can only create leads, so it is safe in browser code. A server route is still better: it can pass on the visitor's IP and retry on failure. If the browser posts directly, use your framework's public prefix (NEXT_PUBLIC_, VITE_). See Authentication.

3

Send your first lead

Send a POST request to create a lead. Here's a quick example using cURL:

terminal
curl -X POST https://gallant-goshawk-513.convex.site/v1/leads \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $DB_API_KEY" \
  -d '{
    "formSlug": "acme-contact",
    "email": "hello@example.com",
    "name": "Jane Doe",
    "message": "Hello from 1db!"
  }'

Or integrate directly in your app:

submit-lead.ts
// On your server (route handler, server action, serverless function)
async function submitLead(formData: Record<string, unknown>) {
  const response = await fetch(`${process.env.DB_API_ENDPOINT}/v1/leads`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "X-API-Key": process.env.DB_API_KEY!,
    },
    body: JSON.stringify({ formSlug: process.env.DB_FORM_SLUG, ...formData }),
  });

  const body = await response.json();
  // body.error is a readable string; body.code says what went wrong
  if (!response.ok) throw new Error(body.error ?? "Submission failed");
  return body; // { success: true, leadId, duplicate }
}

Every field rule, error code and the retry-safe v2 contract are in the API reference.

You're all set

Your lead will appear in your dashboard within seconds. From there you can:

  • View and search all your leads
  • Configure email notifications
  • Add webhooks for custom integrations

Next steps