Use maxclicks in Replit
Connect your Replit project to customer records, events, and prepared campaigns in maxclicks. Store the key as a secret and make API requests from your server runtime.
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.
Get an API key
Create a key in the maxclicks app under Settings, Developers (https://app.maxclicks.ai/space/-/settings/developers). A key is scoped to one space and looks like max_.... The suppression endpoints are the only ones that need a key whose owner has admin permission on the space.
Store the key as a Secret
Open Secrets
In the Replit left sidebar, open the Secrets tool (the padlock icon).
Add the key
Add a secret named
MAXCLICKS_API_KEYwith yourmax_...value. Both the SDK and the CLI read this variable by default, so no key appears in your source.
Do not paste the key into a file or a Repl that is public or forked. Secrets are injected as environment variables at run time and are not committed.
Option 1: Node SDK
Use the SDK for application code. It ships TypeScript types, automatic pagination, typed errors, and bounded retries: 429 on all calls, and 5xx/transport failures for reads and keyed writes.
The npm maxclicks entry is a placeholder. The name currently resolves to a
placeholder that exports no client. The SDK examples require a client built
from source; use the HTTP quickstart if you do not have one.
Build and install the Node client from source before running these examples. Installing the placeholder npm entry does not satisfy this prerequisite.
Construct the client with no argument to read MAXCLICKS_API_KEY from the Secret, then call a method:
import { Maxclicks } from 'maxclicks'
const mc = new Maxclicks() // reads MAXCLICKS_API_KEY
const me = await mc.me()
console.log(me.space?.name)
const contact = await mc.records.upsert('students', {
email: '[email protected]',
firstName: 'Ada',
tags: ['beta'],
})
console.log(contact.id)
Pass options to the constructor to override defaults:
const mc = new Maxclicks({
apiKey: process.env.MAXCLICKS_API_KEY,
baseUrl: 'https://api.maxclicks.ai/v1',
timeoutMs: 60000,
maxRetries: 2,
})
On success a call returns the data directly. On failure it throws a typed error, one of the MaxclicksError subclasses. See the Node SDK reference for the full method list.
Option 2: CLI
The CLI examples require a built source checkout with the maxclicks command available in your Replit environment. maxclicks-cli is not published to npm, so neither npx maxclicks-cli nor a global npm install provides it.
If you do not have that source build, use the first HTTP request above and the current REST reference. The CLI reference documents the source interface and its current API coverage.
Once the source CLI is available, it prints JSON to stdout and structured errors to stderr for shell scripts and tools such as jq.
The CLI reads MAXCLICKS_API_KEY from the Secret. Confirm the key and its space with whoami, then run commands:
maxclicks schemas list --type contact
maxclicks records upsert students --data '{"email":"[email protected]","firstName":"Ada"}'
maxclicks events fire purchase-completed --data '{"eventId":"ord_1","amount":42}'
maxclicks api GET /schemas
--all requests list pages as a flat array, subject to the API's traversal limit; it does not guarantee a full workspace export. Run maxclicks <command> --help for options. See the CLI reference for every command.
Which to use
| Use | Choose |
|---|---|
| A first request without a maxclicks package, or a newer API operation | Direct HTTP |
| Application code with types and pagination helpers | Node SDK, after building the source client |
| Shell scripts and JSON pipelines | CLI, when a source build is available |