Guides

AI agents, MCP and CLI

Tell an agent “set up 1DB for acme.com” in any project. It adds the website, writes its keys to the project, wires the form and sends a test lead.

Why use it

Without it, connecting a site means copying an endpoint, a key and a form slug from the dashboard into the project, then writing the form code. Your agent is already in the project and knows its framework, so it can do all of that and prove a lead arrives, without you leaving the editor. You only approve the sign-in once, and add the keys to your host when you deploy.

Before you start

  • A 1DB account where you are an admin of the organization (agent tokens act as their admin).
  • Node 18 or newer (node -v), for npx.
  • Claude Code for the one-command setup. Claude and ChatGPT connect by signing in, and other agents work too: see Other MCP clients.

1. Connect once

In your own terminal, from any folder:

bash
npx @1db/cli setup

It opens 1DB in your browser to approve the sign-in (pick the organization and the scopes), then adds the 1DB MCP server to Claude Code for every project. Restart Claude Code to load it. You do this once per computer, not once per project.

It creates an agent token (1db_at_…) that acts for you in that organization. It stays in your user config, never in a project. The per-website keys (1db_…) an agent writes into a project can only send leads. See or revoke tokens in Settings → API keys → Agent tokens.

For AI agents reading this

Only a person can create an agent token. If you don't have one, ask your user to run npx @1db/cli setup or to create a token in Settings. Don't try to sign up or sign in to 1DB yourself.

Not in CI or a shared machine

The token can manage your organization. Run setup on your own computer, never in a CI job, a container image or a project script.

2. Ask for it

Open Claude Code in the website's project and say:

text
Set up 1db for acme.com

Claude calls onboard_website, writes DB_API_ENDPOINT, DB_API_KEY and DB_FORM_SLUG to the env file (and git-ignores it), wires the form, then uses send_test_lead and list_leads to prove leads arrive. Asking twice is safe: the same website comes back, not a copy.

For a site that is already connected and needs another form:

text
Add a quote request form to acme.com in 1db

Claude calls create_form, which returns the new form's slug and fields. The site keeps its ingest key; the new form posts with its own formSlug. Pass a template (quote-request, pickup-request, contact) for ready-made fields, and defaultLeadType / defaultProductType for leads that arrive without them. See form templates and defaults.

3. Go live

.env.local only exists on your computer. The deployed site sends nothing until its host has the same variables:

  1. Add DB_API_ENDPOINT, DB_API_KEY and DB_FORM_SLUG (with any prefix the project uses) to your host's production environment variables: Vercel → Settings → Environment Variables, Netlify → Site configuration → Environment variables, Cloudflare → Settings → Variables.
  2. Redeploy. Most hosts only read new variables on the next deploy.
  3. Submit the real form on the live site, then check it arrived: npx @1db/cli leads acme.com, or ask Claude to list the leads.

A test lead from the agent proves the key and form slug. Only a submission on the live site proves the deployed form.

Already using 1DB?

Nothing changes for sites that already send leads: the endpoint and keys are the same. To confirm a project is wired up right, run this in its root folder:

bash
npx @1db/cli check          # compare the project's DB_* vars with 1DB
npx @1db/cli check --send   # also post one test lead with those exact values

It finds the variables in the project's .env* files (including older 1DB_ names and NEXT_PUBLIC_/VITE_ prefixes), checks the endpoint, key and form slug against the website, and checks the env files are git-ignored. It exits non-zero when something is wrong. To hand it to the agent in that project instead:

text
This project already sends leads to 1DB. Check the setup without rewriting working code:
1. Run `npx @1db/cli@latest check` in the project root and read the result. If it says I'm not
   logged in, stop and ask me to run `npx @1db/cli setup` in my own terminal.
2. Fix only what it marks ✗ (wrong endpoint, wrong form slug, env file tracked by git).
3. Don't rename env vars or replace values that work. Don't put any 1db_at_ token in the project.
4. Tell me which variables the live site's host needs, if any are missing there.

Check on your sites

text
Which of my 1db sites need attention?
Why has acme.com stopped getting leads?
  • list_websites { q, attention }: every website with its health (last lead, leads in 30 days, issues such as leads_stopped or unreachable). attention: true keeps only sites with problems; q searches name, slug and domain.
  • get_site_health { website }: a plain-English diagnosis, most urgent first, plus lead counts, each form's last lead, key status and forwarding failures. Start here when a site seems broken.
  • issue_ingest_key { website }: the live ingest key, or a new one when every key was revoked. The host's DB_API_KEY must then be updated and the site redeployed.
  • list_leads { website, form, status, since, limit, cursor }: newest first, one page at a time; since takes ms or an ISO date.
  • get_lead { id }: one lead in full, with its sync error and (routing scope) each forwarding attempt.
  • retry_leads { ids, rule? }: restarts failed forwards once the cause is fixed, or forwards the leads through one rule. Needs the routing scope.
  • delete_test_leads { ids, confirm: true }: removes leads sent by send_test_lead. Real leads can't be deleted with an agent token.

From a terminal: 1db websites --attention, 1db health acme.com, and 1db check [--send] in a site's project.

Find what's wrong and fix it

text
What needs attention across my sites?
What's wrong with acme.com? Fix it, open the PR and merge it.
  • get_portfolio_status: every site with a warning or worse, most urgent first, the same problem grouped across sites, and which sites your leads come from.
  • get_site_map { website }: where a site lives. Its DNS zone, hosting project, GitHub repo (with clone commands), analytics, Search Console property, forms and keys, plus what 1DB can't see yet.
  • list_lead_requests { website, errors, since }: what the site's form actually sent to 1DB, accepted or refused and why. A revoked key or a renamed field shows up here first. Needs the leads scope.
  • list_code_activity { kind: "prs" | "issues", website }: open pull requests or issues on your site repos, through your GitHub connection.
  • get_fix_brief { website, issue? } (or the fix_site prompt): everything the agent needs in one brief. It covers what's wrong, the evidence, and where the code and hosting live. It also gives the steps to follow: record it, clone, reproduce, fix on a branch, open the PR, merge, check the live site and close it.
  • list_work and report_work: the work log. Agents record each problem they find and what they did about it, with the PR link, so you and the next agent can see where every site stands.

From a terminal: 1db status, 1db info acme.com, 1db requests acme.com --errors, 1db prs, 1db clone acme.com (repo, env values and how to run it) and 1db fix acme.com --run claude, which starts Claude Code with the brief.

Fewer tools: connect with /api/mcp?toolsets=core,ops to list only the tools you need (leads, config, launch, packs, seo, ops, doctor, insights). Leave it off to get every tool.

Check a site end to end, and how it does in Google

text
Run every check on acme.com and tell me what to fix first.
Which of my sites' queries are on page two of Google?
  • diagnose_site { website, live? }: every check on one site, grouped into hosting, DNS and TLS, lead path, tracking and search. Each one says ok, warn or fail, shows what 1DB saw, and gives the next step. It covers the last production deploy, the TLS certificate (expiring within 14 days), whether the bare domain and www redirect to one host, refused form submissions, a revoked key still in use, the PostHog proxy, and noindex, robots.txt, sitemap, canonical and title tags. 1DB checks every site once a day. live: true checks it again now (rate-limited per organization).
  • get_site_seo { website?, months? }: from your Search Console data, the queries on page two (positions 11 to 20), queries people see but don't click, queries that slipped since last month, and sites that get Google clicks but no leads. Rows show search volume and cost per click when 1DB tracks the keyword. Leave out website to see every site at once.

New problems from the daily check also show in get_portfolio_status, on the dashboard, and in the fix brief, which lists the doctor's failing checks. From a terminal: 1db doctor acme.com --live and 1db seo acme.com (1db seo queries for every site). Connect with /api/mcp?toolsets=core,doctor for just these tools.

Traffic and leads across every site

text
Which of my sites got the most recorded traffic and saved submissions this month?
How did acme.com do over the last 7 days?
  • get_analytics { days, website, sort, daily }: pageviews, daily session totals, search-referred pageviews, Google search clicks and impressions, and saved submissions for every website in one call, plus portfolio totals and per-day series. conversionRate is unavailable (null) without validated attribution and complete tracking. days is 1 to 90 (default 30, UTC days ending today), or up to 500 with website; sort is leads, pageviews, sessions, conversion, clicks or impressions. With website it covers that site day by day.
  • get_analytics_monthly { months, website }: the same numbers per calendar month, up to 24 months back, for year to date and trends.
  • Traffic comes from PostHog, read hourly through the PostHog connection in Settings → Connections (a personal API key with query:read). Google search comes from Search Console, read daily through its connection (a service account key); its final data runs about 2-3 days behind. When traffic.connected or search.connected is false that feed has no connection and reads as zero. Leads are always live and leave out test leads from 1db send or at reserved addresses such as @example.com.

From a terminal: 1db analytics for every site, 1db analytics acme.com --days 7 for one, --json for the raw response. Over HTTP: GET /v1/agent/analytics with the sites scope.

Weekly reports and alerts

text
Write this week's report for all my sites
Email ops@acme.com when any site stops getting leads or goes down
Post to our Slack when Google clicks drop 40% on acme.com
  • get_site_report { website?, period: "week" | "month" } (or the weekly_report prompt): one site or every site, in Markdown. It shows traffic, Google clicks and leads against the period before, what broke, the work log, the best and worst sites, the biggest movers, where leads come from, search opportunities, and what to do next, each step with the command that does it. Lead counts include test leads.
  • list_alerts: the rules, what is firing now, recent deliveries and the weekly digest. With the sites scope only, channel targets are hidden.
  • set_alert { id?, condition, website?, threshold?, issueCode?, channels, mute? }: add or change a rule. Conditions are leads_stopped (no leads for longer than the site usually goes, or threshold days), site_down, deploy_failing, cert_expiring, traffic_drop and search_clicks_drop (a % drop this week against last), ingest_refusals (refused submissions in 24 hours), leads_held (leads held by the flood cap in 24 hours) and issue (any issue code). Leave out website to watch every site.
  • list_alert_channels, set_alert_channel, delete_alert_channel: where alerts go. Email takes up to 10 addresses, Slack an incoming webhook URL, and a webhook any public https:// URL. Slack and webhook URLs are stored encrypted and only shown as a hint afterwards.
  • test_alert { rule? | channel? } sends a test now. set_weekly_digest { enabled, channels } sends the all-sites report every Monday to email or Slack channels. It is off until you turn it on.

1DB checks the rules every hour, after it reads your sites. An alert is sent once when it starts and once when it clears, grouped into one message per channel. A muted rule keeps tracking but sends nothing. Channels, rules and tests need the routing scope, because they send data out of 1DB. Reading the report needs sites.

Webhook requests carry X-1DB-Signature: t=<unix time>,v1=<hex>, an HMAC-SHA256 of `${t}.${body}` under the signing secret that is shown once when the channel is made. They also carry X-1DB-Event and an Idempotency-Key. Failed sends are retried up to 5 times.

bash
1db report all --week --md report.md       # every site, written to a file
1db report acme.com --month                 # one site, last 30 days
1db channels add email "Ops" --to ops@acme.com
1db channels add webhook "Pager" --url https://hooks.acme.com/1db   # prints the signing secret once
1db alerts add leads_stopped --channel Ops  # every site
1db alerts add traffic_drop acme.com --channel Ops --threshold 50
1db alerts mute <id> --for 7d
1db alerts digest on --channel Ops

In the dashboard: Settings → Alerts. Over HTTP: GET /v1/agent/report, GET|POST /v1/agent/alerts and GET|POST /v1/agent/alerts/channels.

Compare sites and debug one

text
Which of my sites converts best, and which one lost leads this month?
Where does acme.com's traffic come from?
acme.com gets visitors but no leads. Why?
  • compare_sites { metric, days } ranks every site on leads, pageviews, conversion (saved leads per 1,000 pageviews) or Google clicks, with each site's share of the organization's leads and traffic and its change against the period before. It names the best and worst performers, the biggest drop and sites with traffic but no leads.
  • get_site_traffic { website, view, days } reads PostHog live: top pages, referrers, sources, devices, countries or Core Web Vitals. Every query is limited to your own sites' hostnames. Leave out website to see every site side by side.
  • get_site_funnel follows one site from pageview to CRM: form views, submit attempts, posts to 1DB, refusals, saved leads, and leads synced or forwarded. It names the step that loses visitors. A step with no data says so instead of reading zero.
  • trace_visitor { id } takes a lead id or a PostHog visitor id and shows the landing page, referrer, UTMs, pages seen, the lead and where it went. It needs the leads scope and never returns contact details.
  • list_deploys and get_site_logs read the site's host (Vercel, Cloudflare Pages or Workers) through your connection: failed builds with their error, and runtime errors where the host keeps them.

Live answers are cached for 5 minutes, and each organization has a limit on live provider calls. Provider keys stay in 1DB. From a terminal: 1db compare, 1db traffic [site] --sources, 1db funnel acme.com, 1db trace <lead-id>, 1db deploys acme.com and 1db logs acme.com --errors. Connect only these tools with /api/mcp?toolsets=insights.

Configure it

With the matching scopes, an agent can finish the setup too:

text
Make the quote form on acme.com default to product type pallets
Email ops@acme.com when the quote form gets a lead
Forward every new lead to https://api.acme.com/leads with our API key
  • update_website, list_product_types: name, domain, status, product types and the website-level fallback product type.
  • get_form, update_form: rename a form, change its slug, replace its fields or set its default lead type and product type.
  • set_form_notifications: notification emails (up to 10) and a webhook per form.
  • list_forwarding_rules, create_forwarding_rule, update_forwarding_rule, delete_forwarding_rule: send each new lead to an outside endpoint, with a generic or repackify profile. New rules start disabled; secrets are stored and never returned.
  • delete_form, delete_website: need confirm set to the slug. Leads are kept, but a live form posting to it starts failing.

Other tools: get_website, scan_domain, send_test_lead (a real lead: it runs notifications and forwarding), whoami. Destinations must be public https:// URLs.

Token scopes

Each token only does what its scopes allow; anything else gets a 403 naming the missing scope. Pick them when creating a token in Settings or approving a CLI sign-in. whoami shows a token's scopes.

ScopeAllows
sitesAdd websites and forms, change their settings, get ingest keys, send test leads, read and pull search data (from the organization's monthly search budget, shared by all its tokens)
leadsRead leads and their contact details
routingForwarding rules, notification emails and webhooks, alert rules and channels, and retrying a lead's forwards: anything that sends leads somewhere
deleteDelete websites, forms, forwarding rules and test leads

The defaults, sites and leads, cover setting up a site. Give an agent you don't run yourself sites only. Tokens created before scopes existed keep sites and leads.

Test leads are real leads

send_test_lead, 1db send and 1db check --send post through the same endpoint as your site. The lead shows in the dashboard and counts in stats, and it runs the site's CRM sync, notification emails, webhooks and forwarding. It is tagged with source 1db-test so you can find and delete it.

Agents are told to send one per check. If the site already syncs to a CRM or forwards leads, expect one test contact to show up there too.

Keeping tokens safe

  • Two kinds of key. The agent token (1db_at_…) manages your organization and lives in ~/.config/1db/config.json and your Claude Code config. The ingest key (1db_…) goes in projects and can only send leads. 1db check fails if an agent token ends up in a project.
  • A token leaked? Revoke it in Settings → API keys → Agent tokens; it stops working at once. Then run npx @1db/cli setup --relogin for a new one.
  • You'll know when one is made. Organization owners get an email whenever a new agent token is created.
  • Switch organization with npx @1db/cli setup --relogin and pick the other one when approving.
  • Sign out with npx @1db/cli logout and claude mcp remove 1db, then revoke the token in Settings.

Troubleshooting

You seeWhat to do
Claude has no 1DB toolsRestart Claude Code after setup. claude mcp list should show 1db.
401 when the MCP server connects, or from the APIThe token is missing, malformed, wrong or revoked. Run npx @1db/cli setup --relogin, or create a new token in Settings. An agent should ask its user for one rather than sign in itself.
403 missing scopeThe message names the scope. Run npx @1db/cli setup --relogin and tick it.
404 website not foundThe token is for another organization, or the slug is wrong. whoami and websites show both.
429Over 60 requests a minute. Wait a minute.
Sign-in code expiredCodes last 10 minutes. Run the command again.
Leads arrive locally but not from the live siteThe host is missing the variables, or wasn't redeployed. See Go live.
Lead rejected with FORM_NOT_FOUNDDB_FORM_SLUG isn't a real form. Slugs look like acme-contact; npx @1db/cli check lists the right ones.
Lead rejected with INVALID_API_KEYThe key was revoked. npx @1db/cli keys acme.com (or issue_ingest_key) gives the live one; update the host's DB_API_KEY and redeploy.
A site stopped sending leadsnpx @1db/cli health acme.com or get_site_health says what to check. 1db websites --attention lists every site with a problem.

Search: rankings, leads and where to launch next

bash
npx @1db/cli seo portfolio --flag ranks_no_leads   # Google sends visitors, no lead in 30 days
npx @1db/cli seo portfolio --flag slipping         # rankings, traffic or clicks fell sharply
npx @1db/cli rankings acme.com      # top 3 / top 10 keywords, est. traffic, change vs last month
npx @1db/cli rankings rival.com     # works for any domain, e.g. a competitor (add --refresh to pull it)
npx @1db/cli opportunities --product pallets --region ohio --pull --save
                                    # score each city for a new site by volume, CPC and difficulty
npx @1db/cli seo usage              # this month's search data spend against your budget

Every site gets one SEO row next to its leads: Search Console's clicks where it's connected, otherwise monthly Google rankings from DataForSEO. That makes "which sites rank but get no leads" and "which are slipping" one call. Over MCP the same answers come from get_seo_portfolio, get_site_rankings, score_launch_slots and get_seo_usage, with the sites scope.

Rankings refresh once a month on their own. Pulling fresh numbers on demand (keywords pull, rankings --refresh, opportunities --pull) spends from your organization's monthly search data budget. Once it's used up, those calls answer rate_limited until the 1st; reading stored numbers is always free.

Claude and ChatGPT connectors

The MCP server signs you in through the browser (OAuth), so apps that can't send a token header can use it too. Menu names differ by app and plan; the server address is the same everywhere:

text
https://www.1-db.com/api/mcp
  • Claude (claude.ai and the desktop app). Add a custom connector in the connector settings and paste the address. Leave any OAuth client ID and secret empty: the app registers itself.
  • ChatGPT. Custom MCP connectors need developer mode, in the apps and connectors settings. Create a connector there, paste the address and choose OAuth as the authentication. ChatGPT works best with a short tool list, so add toolsets to the address, for example https://www.1-db.com/api/mcp?toolsets=leads,insights,reports.
  • Claude Code, without the CLI. claude mcp add --scope user --transport http 1db https://www.1-db.com/api/mcp, then run /mcp in a session and sign in.

Each one opens a 1DB page that names the app asking, where you pick the organization and the scopes and approve. You must be an admin of that organization. Approving creates an agent token named after the app, ending in “(connector)”. It works until you revoke it in Settings → API keys → Agent tokens, and owners get the same email as for any new token.

Approve only what you started

The page shows the name the app gave itself, which 1DB can't verify. If a sign-in page opens that you didn't ask for, deny it.

Toolsets

The server lists every tool unless the address names toolsets. core (websites, forms, onboarding) is always on. Add any of leads, config, insights, reports, doctor, ops, seo, packs, shots and launch, separated by commas:

text
https://www.1-db.com/api/mcp?toolsets=leads,insights,reports

Other MCP clients

Any Streamable HTTP client (Cursor, Windsurf, VS Code and others) can sign in the same way if it supports OAuth. For one that doesn't, or for a script, create a token in Settings (or run npx @1db/cli mcp after logging in) and send it as a header:

bash
claude mcp add --scope user --transport http 1db https://www.1-db.com/api/mcp \
  --header "Authorization: Bearer 1db_at_..."

A missing, malformed, wrong or revoked token is refused when the client connects, with HTTP 401 and a WWW-Authenticate header that points at the sign-in, so a bad token never looks like a working connection.

Or use the CLI yourself

bash
npx @1db/cli login           # browser sign-in (or --token 1db_at_...)
npx @1db/cli init acme.com   # scan + add the site, write DB_* vars to .env.local
npx @1db/cli websites --attention   # only sites with problems (add text to search)
npx @1db/cli health acme.com # what's wrong with a site, in plain English
npx @1db/cli check acme.com  # compare this project's DB_* vars with 1DB
npx @1db/cli check --send    # ...and post one test lead with the project's own values
npx @1db/cli leads acme.com --since 2026-01-31   # see it arrive (date or ms)
npx @1db/cli delete tests acme.com --confirm      # then remove the test leads
npx @1db/cli lead <id>       # one lead: data, sync error, forwarding attempts
npx @1db/cli retry <id> ...  # retry failed CRM syncs and forwards (--rule to forward through one rule)
npx @1db/cli keys acme.com   # print the site's endpoint, key and form slug
npx @1db/cli form acme.com --name "Quote request" --fields "email*,name,phone:phone,message:textarea"
                             # add another form to the site, print its slug
npx @1db/cli product-types add "Pallets"   # new organizations start with no product types
npx @1db/cli form acme.com --template quote-request --product-type pallets
                             # or start from a template, with form defaults
npx @1db/cli form-edit acme-quote-request --lead-type buy
npx @1db/cli site acme.com --product-type pallets --status active   # website-level fallback
npx @1db/cli notify acme-quote-request --emails ops@acme.com
npx @1db/cli forwarding add --name "Our API" --endpoint https://api.acme.com/leads --auth-token ... --profile generic --enable

Run it from the project's root folder: init and check read and write the env files there. init never replaces values a project already has; it lists the differences and leaves them (pass --force to overwrite).

Every command takes --json. Use --prefix NEXT_PUBLIC_ or --prefix VITE_ when the variables must reach the browser. Install it with npm i -g @1db/cli to type 1db instead of npx @1db/cli.

Or call the agent API

bash
curl -X POST https://gallant-goshawk-513.convex.site/v1/agent/onboard \
  -H "Authorization: Bearer $ONEDB_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain":"acme.com"}'
  • POST /v1/agent/onboard { domain, name?, fields? }: scans the domain and creates the website with its ingest key and contact form. Retrying returns the same website with created: false.
  • POST /v1/agent/forms { website, name?, slug?, fields?, preset?, template?, defaultLeadType?, defaultProductType? }: adds a form to an existing website (name or template required). Fields default to the preset, then the organization's default preset, then the standard contact fields. Retrying with the same slug (or name) returns the same form.
  • GET /v1/agent: an index of every route.
  • GET /v1/agent/website?website=acme.com: endpoint, ingest key, key status, forms and fields. It never creates a key: apiKey is null when every key was revoked.
  • POST /v1/agent/website/key { website }: returns the live ingest key, or makes one (201) when none is left. The host's DB_API_KEY must then be updated.
  • GET /v1/agent/websites?q=acme&attention=1: websites, each with health (last lead, leads in 30 days, issues). attention=1 keeps only sites with problems.
  • GET /v1/agent/websites/health?website=acme.com: one site's diagnosis (plain English, most urgent first), lead counts, issues, forms, key status and, with the routing scope, forwarding failures.
  • POST /v1/agent/test-lead { website, data?, formSlug? }: sends a real lead through /v1/leads, tagged source 1db-test.
  • GET /v1/agent/leads?website=&form=&status=&since=&limit=&cursor=: newest leads first, one page at a time. since takes ms or an ISO date; pass nextCursor back as cursor.
  • GET /v1/agent/lead?id=: one lead in full; its forwarding attempts only with the routing scope.
  • POST /v1/agent/leads/retry { id | ids, rule? } (routing): restarts failed CRM syncs and failed forwards, or with rule forwards the leads through that rule. Up to 50 leads.
  • POST /v1/agent/leads/delete { id | ids, confirm: true } (delete): test leads only (source 1db-test); others come back in notTest. Up to 100.
  • GET /v1/agent/me, POST /v1/agent/scan.
  • POST /v1/agent/website/update { website, name?, domain?, status?, defaultProductType?, productTypes? }, GET /v1/agent/product-types, POST /v1/agent/product-types { name, slug?, category? }, POST /v1/agent/product-types/import { rule } (routing; adds the product types that rule's destination accepts).
  • GET /v1/agent/form?form=slug, POST /v1/agent/forms/update { form, name?, slug?, fields?, defaultLeadType?, defaultProductType? } ("" clears a default).
  • POST /v1/agent/forms/notifications { form, email?: { enabled, recipients }, webhook?: { enabled, url, headers? } } (routing).
  • GET|POST /v1/agent/forwarding, POST /v1/agent/forwarding/update { id, ..., profile?: "generic" | "repackify" } (routing); POST /v1/agent/forwarding/delete { id, confirm: name } (delete).
  • POST /v1/agent/forms/delete { form, confirm }, POST /v1/agent/website/delete { website, confirm } (delete).

Errors come back as { "error": { "code", "message", "hint"? } }, with codes like invalid_argument, unauthorized, forbidden and not_found: the full list is in the API reference. Limit: 60 requests a minute per token (bursts to 120).

What lands in the project

.env.local
DB_API_ENDPOINT=https://gallant-goshawk-513.convex.site
DB_API_KEY=1db_...
DB_FORM_SLUG=acme-contact
# one per extra form made with create_form
DB_QUOTE_REQUEST_FORM_SLUG=acme-quote-request

The form posts to ${DB_API_ENDPOINT}/v1/leads with the key in an X-API-Key header and formSlug in the JSON body. A server route is preferred, and keeps the variables unprefixed. If the browser posts directly, the public prefix is fine (NEXT_PUBLIC_DB_API_KEY, VITE_DB_API_KEY, via --prefix): the ingest key can only create leads.

The form code itself is in the Next.js, React and HTML forms guides, which use the same variable names. Agents can read /llms.txt for a plain-text index.