Back to The Times of Claw

DenchClaw API Guide: Automate Anything

DenchClaw API guide: automate CRM operations, integrate external tools, build webhooks, and trigger AI workflows via the OpenClaw API and bridge SDK.

Mark Rachapoom
Mark Rachapoom
·6 min read
DenchClaw API Guide: Automate Anything

DenchClaw API Guide: Automate Anything

DenchClaw exposes its data and AI capabilities through several API surfaces. Whether you're building an integration, automating workflows from external tools, or connecting your own apps to DenchClaw's data, this guide covers every access pattern.

API Surfaces Overview#

DenchClaw has four API surfaces:

  1. DuckDB direct access — SQL queries against the database file
  2. OpenClaw HTTP API — REST-style agent API for external integrations
  3. Bridge API (window.dench) — JavaScript SDK inside Dench Apps
  4. Webhook endpoints — receive external events into DenchClaw

1. DuckDB Direct Access#

The fastest and most powerful access pattern. Your data is in ~/.openclaw-dench/workspace/workspace.duckdb — a plain DuckDB file you can query from any language.

Python:

import duckdb
 
conn = duckdb.connect('~/.openclaw-dench/workspace/workspace.duckdb')
 
# Query people
people = conn.execute("""
    SELECT "Full Name", "Email", "Status", "Company"
    FROM v_people
    WHERE "Status" = 'Lead'
    ORDER BY "Full Name"
""").fetchall()
 
# Insert a new contact
conn.execute("""
    INSERT INTO entries (object_id, created_at, updated_at)
    VALUES ((SELECT id FROM objects WHERE name = 'people'), NOW(), NOW())
""")

Node.js:

import Database from 'duckdb';
const db = new Database.Database('~/.openclaw-dench/workspace/workspace.duckdb');
 
db.all("SELECT * FROM v_people WHERE \"Status\" = 'Lead'", (err, rows) => {
  console.log(rows);
});

CLI:

duckdb ~/.openclaw-dench/workspace/workspace.duckdb \
  "SELECT COUNT(*) FROM v_deals WHERE Stage = 'Closed Won'"

When to use DuckDB direct:

  • Reporting and analytics scripts
  • Data exports to other systems
  • Performance-critical queries
  • Integration scripts running on the same machine

2. OpenClaw HTTP API#

The HTTP API lets external systems send messages to the DenchClaw agent and receive responses.

Base URL: http://localhost:19001

Send a message to the agent#

curl -X POST http://localhost:19001/api/sessions/main/messages \
  -H "Content-Type: application/json" \
  -d '{"content": "Add a new lead: Sarah Chen from Stripe, email sarah@stripe.com"}'

Response:

{
  "messageId": "msg_abc123",
  "status": "processing",
  "sessionId": "main"
}

Poll for response#

curl http://localhost:19001/api/sessions/main/messages/msg_abc123

Create a background session for automation#

curl -X POST http://localhost:19001/api/sessions \
  -H "Content-Type: application/json" \
  -d '{"label": "nightly-enrichment"}'

Common automation patterns#

Trigger from a web form submission:

// In your web backend (Node.js)
app.post('/contact-form', async (req, res) => {
  const { name, email, company, message } = req.body;
  
  await fetch('http://localhost:19001/api/sessions/main/messages', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      content: `New inbound lead: ${name}, ${email}, ${company}. Message: ${message}. Source: Website Form. Create entry in Leads object.`
    })
  });
  
  res.json({ success: true });
});

Trigger from Zapier or Make: Set the webhook action to POST to http://[your-server]:19001/api/sessions/main/messages with the content field describing the operation.

Scheduled automation via cron:

# Add to crontab: run every morning at 7am
0 7 * * * curl -s -X POST http://localhost:19001/api/sessions/main/messages \
  -H "Content-Type: application/json" \
  -d '{"content": "Run the daily briefing and send to Telegram"}'

3. The Bridge API (window.dench)#

Inside Dench Apps, window.dench is auto-injected. Full reference:

Database operations#

// Query any DuckDB view
const leads = await dench.db.query(
  'SELECT * FROM v_people WHERE "Status" = \'Lead\' LIMIT 100'
);
 
// Query with parameters
const byOwner = await dench.db.query(
  'SELECT * FROM v_deals WHERE "Owner" = ? ORDER BY "Value" DESC',
  [ownerName]
);
 
// Execute write operations (requires db:write permission)
await dench.db.execute(
  'UPDATE entry_fields SET value = ? WHERE entry_id = ? AND field_id = ?',
  [newValue, entryId, fieldId]
);

CRM operations#

// Create a new entry
const newLead = await dench.objects.createEntry('people', {
  'Full Name': 'Sarah Chen',
  'Email': 'sarah@stripe.com',
  'Status': 'Lead',
  'Company': 'Stripe'
});
 
// Update an entry
await dench.objects.updateEntry('people', entryId, {
  'Status': 'Qualified',
  'Last Contacted': new Date().toISOString().split('T')[0]
});
 
// List entries with filters
const customers = await dench.objects.listEntries('customers', {
  filters: [{ field: 'Health Score', operator: 'lt', value: 60 }],
  orderBy: 'ARR',
  orderDir: 'desc',
  limit: 50
});

AI chat#

// One-shot AI call
const summary = await dench.chat.oneShot(
  `Summarize this deal pipeline data: ${JSON.stringify(deals)}. Highlight top risks.`
);
 
// Multi-turn conversation session
const session = await dench.chat.createSession();
await dench.chat.send(session.id, 'Analyze my pipeline health');
const response = await dench.chat.receive(session.id);

Events (real-time)#

// Listen for new entries
dench.events.on('entry:created', (event) => {
  if (event.objectName === 'people') {
    refreshContactTable();
  }
});
 
// Listen for field changes
dench.events.on('entry:updated', (event) => {
  if (event.field === 'Status' && event.newValue === 'Customer') {
    triggerOnboardingWorkflow(event.entryId);
  }
});

Scheduling#

// Create a cron job from inside an app
await dench.cron.schedule(
  { everyMs: 3600000 }, // every hour
  'Refresh lead enrichment for new leads'
);
 
// One-off scheduled action
await dench.cron.at(
  new Date('2026-04-01T09:00:00'),
  'Send Q2 pipeline review to the team'
);

4. Webhooks#

DenchClaw can receive webhooks from external services and trigger agent actions.

Register a webhook endpoint:

Create a webhook endpoint that: when triggered, creates a Lead entry from the POST body fields: name, email, company, source

DenchClaw creates an endpoint URL like: http://localhost:19001/webhooks/abc123def456

Use cases:

  • Form submissions from Typeform, Tally, Google Forms
  • Payment events from Stripe
  • CRM events from Salesforce (for sync workflows)
  • App events from your product (new user signup → create Lead)

Example: Stripe payment → create Customer:

Create a webhook that: when a Stripe checkout.session.completed event arrives, create a Customer entry with name from metadata, email from customer_details.email, ARR from amount_total/100, Plan from metadata.plan

Authentication#

For production deployments, secure your API:

# Set API key in OpenClaw config
openclaw config set api.key "your-secret-key"
# Use in requests
curl -H "X-API-Key: your-secret-key" \
  http://localhost:19001/api/sessions/main/messages \
  ...

For Dench Apps, authentication is handled automatically via same-origin.

Rate Limits#

DenchClaw doesn't enforce rate limits by default. For high-frequency automation:

  • Space bulk operations with await sleep(100) between requests
  • Use DuckDB direct access for read-heavy workloads
  • Use batch operations instead of per-record API calls

For the full DenchClaw platform overview, see what is DenchClaw. For building apps on top of the Bridge API, see build a custom analytics app.

Frequently Asked Questions#

Can I use the OpenClaw API from a remote server?#

If DenchClaw is running locally, the API is only accessible on localhost by default. For remote access, configure --host 0.0.0.0 and secure with an API key + TLS.

How do I handle authentication tokens in Dench Apps?#

Dench Apps run in the same origin as DenchClaw — you don't need tokens for the bridge API. For external API calls from apps, use environment variables set in your workspace config.

Is there an OpenAPI specification?#

Yes — DenchClaw generates an OpenAPI spec at http://localhost:19001/api/spec. Import it into Postman or any API client.

Can I use GraphQL instead of REST?#

Not natively. For GraphQL-style queries, use DuckDB direct access with parameterized SQL, which gives you equivalent flexibility.

How do I debug API calls?#

Enable request logging: openclaw config set logging.api true. Check logs at ~/.openclaw-dench/workspace/logs/api.log.

Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →

Mark Rachapoom

Written by

Mark Rachapoom

Building the future of AI CRM software.

Continue reading

DENCH

© 2026 DenchHQ · San Francisco, CA