Skip to main content
Each project can have a SQLite database hosted on Cloudflare D1. Store user profiles, conversation history, leads, or any data your WhatsApp application needs.

Enable database

  1. Go to project settings → Database
  2. Click “Enable database”
  3. Database provisions automatically via Cloudflare D1

Dashboard features

  • Spreadsheet view - Click cells to select, double-click to edit
  • Table management - Create tables, add/rename/drop columns
  • SQL editor - Run raw queries
  • CSV import/export - Bulk data operations
  • Pagination - 25/50/100/200 rows per page

Column types

TypeDescription
textString values
integerWhole numbers
numberDecimal numbers
booleantrue/false
dateDate without time
datetimeDate with time
jsonJSON objects
arrayJSON arrays
file_urlURL to file
referenceForeign key

Using the database

Platform API

Query and modify data from your backend via REST endpoints. See Database API. Agent steps can access the database by adding a webhook tool that calls these endpoints.

Functions

Cloudflare Worker functions can access the same project database directly via env.DB:
async function handler(request, env) {
  const body = await request.json().catch(() => ({}));
  const vars = body.execution_context?.vars || {};

  const { results } = await env.DB.prepare(
    "SELECT * FROM customers WHERE phone = ?"
  ).bind(vars.phone).all();

  await env.DB.prepare(
    "INSERT INTO audit_logs (event_type, payload) VALUES (?, ?)"
  ).bind("customer_lookup", JSON.stringify({ phone: vars.phone })).run();

  return new Response(JSON.stringify({
    customer: results[0] || null
  }), {
    headers: { "Content-Type": "application/json" }
  });
}
If the function runs as an agent tool, the agent-controlled arguments are inside body.input. If it runs as a workflow function, use body.execution_context, body.flow_info, and body.flow_events. Agent steps can invoke functions as tools to access the database indirectly.