Use maxclicks in Bolt
Connect the app you build in Bolt to customer records, events, and prepared emails in maxclicks. Keep the API key in a server environment and make the first request from backend code.
Create a key at https://app.maxclicks.ai/space/-/settings/developers. A key is scoped to one space. Some operations require an admin key.
The npm maxclicks entry is a placeholder. The name currently resolves to a
placeholder that exports no client, so npm install maxclicks will not give
you a working SDK. The code below shows how the client is used. Until the
release lands, call the Public API over HTTP.
The existing SDK, CLI, and MCP tools cover an earlier API surface. Use the current REST contract for event readiness/identities, deletion polling, workflow history, and new idempotent operations; see client coverage.
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 SDK examples below assume you have built the Node client from source. Its npm entry is currently a placeholder.
Connect the SDK
Install the package
Ask the Bolt agent to install the SDK, or run the command in the Bolt terminal.
# Build and install the source SDK described at /sdks/node.Requires Node.js 18 or newer. Ships both ESM and CommonJS builds.
Store the API key
Add
MAXCLICKS_API_KEYto Bolt's environment variables. Never hardcode the key in client code. Call maxclicks from a server route so the key stays server-side.Call the API
import { Maxclicks } from 'maxclicks' const mc = new Maxclicks() // reads MAXCLICKS_API_KEY // Confirm the key and its space const me = await mc.me() console.log(me.space?.name) // 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]' } }, })
Keep the API key on the server. A key in browser code is exposed to every visitor. Route SDK calls through a Bolt backend route, not the client bundle.
Configuration
Pass options to the constructor, or set MAXCLICKS_API_KEY and call new Maxclicks().
- Name
apiKey- Type
- string
- Description
Space API key. Defaults to
MAXCLICKS_API_KEY.
- Name
baseUrl- Type
- string
- Description
API base. Defaults to
https://api.maxclicks.ai/v1.
- Name
timeoutMs- Type
- number
- Description
Per-request timeout. Defaults to
60000.
- Name
maxRetries- Type
- number
- Description
Extra attempts on
429,5xx, and transport errors. Defaults to2.
- Name
onWarning- Type
- function
- Description
Callback for non-fatal API warnings.
Errors
On success a call returns the data directly. On failure it throws a typed error, one of the MaxclicksError subclasses.
import { MaxclicksNotFoundError, MaxclicksRateLimitError } from 'maxclicks'
try {
await mc.records.get('students', 'missing-id')
} catch (error) {
if (error instanceof MaxclicksNotFoundError) {
// 404
} else if (error instanceof MaxclicksRateLimitError) {
console.log('retry after', error.retryAfterMs)
}
}
| Error | When |
|---|---|
MaxclicksBadRequestError | 400 validation failure |
MaxclicksAuthenticationError | 401 missing or invalid API key |
MaxclicksPermissionError | 403 insufficient permission or space out of scope |
MaxclicksNotFoundError | 404 resource not found |
MaxclicksConflictError | 409 identifier or uniqueness conflict |
MaxclicksRateLimitError | 429 rate limited (carries retryAfterMs) |
MaxclicksServerError | 5xx server error |
The source SDK retries 429 within its budget. It retries 5xx and transport errors on reads and keyed writes, with backoff and Retry-After. Preserve the operation key and payload; reconcile uncertain outcomes.
Give the Bolt agent write access
To let the Bolt agent manage your space while it builds, point it at the MCP server. It exposes maxclicks as tools: list schemas and attributes, upsert records, fire events, send templates, manage webhooks, and trigger workflows. Authenticate with your API key as a bearer token:
https://mcp.maxclicks.ai/mcp
Authorization: Bearer max_...