Use maxclicks in Lovable
Connect the app you build in Lovable to customer records, events, and prepared emails in maxclicks. Use backend code for API calls, or an MCP connection for an assistant that needs to work with your workspace.
Create a key at https://app.maxclicks.ai/space/-/settings/developers. A key is scoped to one space. Some operations require an admin key.
Start with the HTTP request below to verify your workspace, then install the Node SDK for typed API calls in your application.
Make a first request over HTTP
This request runs in server-side JavaScript and needs no maxclicks package. Set MAXCLICKS_API_KEY in your server's secret store, then confirm the returned space before making a write.
const apiKey = process.env.MAXCLICKS_API_KEY
if (!apiKey) throw new Error('Set MAXCLICKS_API_KEY first')
const response = await fetch('https://api.maxclicks.ai/v1/me', {
headers: { Authorization: `Bearer ${apiKey}` },
})
const result = await response.json()
if (!response.ok) throw new Error(result.error?.message ?? 'Request failed')
console.log(result.data.space)
For a runtime without process.env, use its server-side secret API. Keep the key out of browser bundles. Follow the API quickstart to sync a contact and send a prepared template.
The examples below use the Node SDK, which provides types, pagination helpers, and typed errors.
SDK: call maxclicks from the app
Use the SDK for code that runs in the app Lovable builds: upsert contacts, fire events, send templates.
Install the package
Install the SDK in a compatible backend runtime:
npm install maxclicksRequires Node.js 18 or newer. Ships ESM and CommonJS builds.
Store the API key
Add
MAXCLICKS_API_KEYin Lovable's environment variables. Never hardcode the key in client code. Call maxclicks from a server route or edge function so the key stays server-side.Call the API
import { Maxclicks } from 'maxclicks' const mc = new Maxclicks() // reads MAXCLICKS_API_KEY // Upsert a contact by identity (id or slug of the contact schema) const contact = await mc.records.upsert('students', { email: '[email protected]', firstName: 'Ada', tags: ['signup'], }) // Fire an event, which can trigger a workflow or a webhook await mc.events.fire('purchase-completed', { eventId: 'ord_123', amount: 42 }) // Send a template, resolving the recipient by email await mc.templates.send(templateId, { data: { contact: { email: '[email protected]' } }, })
On failure a call throws a typed error, one of the MaxclicksError subclasses (MaxclicksNotFoundError, MaxclicksConflictError, MaxclicksRateLimitError, and others). The SDK retries 429 within its budget; 5xx and transport errors are retried for reads and keyed writes. Preserve the key and payload, and reconcile uncertain outcomes. See the SDK reference for the full method list.
Keep the API key on the server. A key in browser code is exposed to every visitor. Route SDK calls through a Lovable backend route or Supabase edge function.
MCP: give Lovable's agent write access
The MCP server turns maxclicks into tools an MCP client can call. Point Lovable's agent at it and the agent can manage contacts and objects, fire events, send templates, manage webhooks, and trigger workflows while it builds.
Hosted (remote)
Connect to https://mcp.maxclicks.ai/mcp. A client that supports MCP sign-in opens maxclicks so you can choose the workspace and approve what it may do; otherwise send your API key in the Authorization: Bearer header. Verify the connected workspace with whoami before making a write.
Local (stdio)
For a client that supports local stdio, use npx -y maxclicks-mcp with MAXCLICKS_API_KEY in its environment. See the local configuration. Cloud-hosted agents need a reachable remote MCP endpoint; a local laptop process is only available to clients running on that machine.
Tools
The agent can read your schemas and attributes but not create them. Call list_schemas and list_attributes to learn how your data is shaped, then write.
| Area | Tools |
|---|---|
| Meta | whoami |
| Schemas and attributes (read) | list_schemas, get_schema, list_attributes |
| Records | list_records, get_record, create_record, upsert_record, update_record, delete_record, get_contact_audit_trail |
| Events | fire_event, fire_events_batch, list_events |
send_template | |
| Suppressions (admin key) | create_suppression, delete_suppression |
| Webhooks | list_webhooks, get_webhook, create_webhook, update_webhook, delete_webhook, rotate_webhook_secret |
| Workflows | trigger_workflow |