Build on the same runtime we run.
Two HTTP routes are live on this site today: streaming chat and contact capture. The wider API, webhooks, SDKs and SMTP are written as contracts and labelled planned wherever they are not shipped yet.
Two routes, no SDK needed
POST /api/chat streams an answer. POST /api/contact stores a lead in D1.
One request. One stream.
curl -N https://loopnow.in/api/chat \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"What does Growth cost?"}],"page":"/pricing"}' The response is a Server-Sent Events stream. Each frame carries choices[0].delta.content, and the stream ends with [DONE]. The key stays server-side in a Worker binding.
Issued at onboarding
LoopSend credentials are provisioned per workspace. No public host is published yet.
SMTP contractPlanned, not shipped
An MCP server for contacts, campaigns and traces is on the roadmap.
PlannedWrite against the HTTP contract today.
No package is published on npm or PyPI yet. The intended client shape is documented so integration work can start without guessing.
Node / TypeScript
Fetch-based client with SSE parsing and typed request bodies.
Early accessPython
Requests-based client, explicit timeouts and retry guidance.
Early accessWebhooks
Delivery contract, HMAC-SHA256 signing and replay protection.
Design contract
The short version
- The public website API has exactly two endpoints: POST /api/chat and POST /api/contact. Both are same-origin routes on loopnow.in.
- There is no public API key for these routes. The model credential stays in a Cloudflare Worker binding and never reaches a browser.
- Chat streams Server-Sent Events and returns 503 until QWEN_API_KEY is configured in the environment.
- Contact accepts JSON or a normal form post, validates name and email, checks a honeypot, then writes to D1.
- Anything beyond these two routes is either provisioned privately for a workspace or labelled planned, and this page says which is which.
- Every example on this site can be reproduced locally with .dev.vars and a local D1 database.
What these docs cover, and what they refuse to cover
LoopNow publishes documentation for the parts of the platform a developer can reach today. That set is smaller than the navigation implies, and this page is deliberately blunt about where the boundary sits. The public website exposes two same-origin endpoints: one streams a grounded answer from the site assistant, and one accepts an enquiry and writes it to a database. Everything else — workspace keys, campaign objects, call records, webhook subscriptions, SDK packages — is either provisioned privately for a single workspace or not built yet. Neither category belongs in a reference page that reads like a public contract.
The rule behind that decision is simple. If you cannot find the behaviour in this repository, it does not get an endpoint row. A developer who copies a curl command, gets a 404 and loses an afternoon has been lied to by documentation, and that cost lands on the team that wrote the page. So each route described here maps to a file: the chat handler, the contact handler, the shared rate-limit table, and the migration that creates it. If a route is removed tomorrow, the page that describes it has to change in the same commit.
That leaves three useful things you can do with these docs. You can call either endpoint from a terminal and know what comes back. You can reproduce both locally, including the failure modes, without touching production. And you can tell the difference between a capability that exists, one that is issued on request, and one that is only an intention. The third distinction matters most: it is the difference between planning an integration and planning around a rumour.
Two live endpoints, one honest scope
POST /api/chat takes a short conversation array and an optional page hint, then proxies a streaming completion from a Qwen model served behind the team’s own gateway. It keeps the last twenty messages, rejects any single message longer than four thousand characters, and caps callers at twelve requests per minute per IP address. When the model credential is missing the route answers 503 with a plain JSON sentence instead of pretending to think. When the upstream gateway times out after forty-five seconds it answers 504. The success path is a text/event-stream body passed straight through to the browser.
POST /api/contact is the quieter of the two. It reads either JSON or a urlencoded form, trims and validates the name and email, returns success immediately for anything that fills the hidden company_url field, and otherwise inserts a row into the contacts_v2 table through the D1 binding. Five submissions per hashed IP per minute are allowed. A browser form post gets a 303 redirect back to the contact page with a query flag; a fetch call that asks for JSON gets a 201 and a small success object.
Both endpoints share one design constraint: they run in the same Worker as the rendered site, so they inherit its deployment, its secrets and its database. There is no separate API host to allowlist, no second TLS certificate to pin, and no cross-origin preflight to configure. The trade-off is that neither route is a general-purpose integration surface. They exist to make one website work, and they are documented so that the website’s behaviour is inspectable rather than mysterious.
- POST /api/chat — messages[], page?, streamed SSE
- POST /api/contact — name, email, company, phone, intent, message, consent
- GET on either route — 405 with a JSON body
- No Authorization header is read on either route
- No CORS headers are emitted, so browsers stay same-origin
How the documentation is organised
The hub you are reading is orientation, not reference. It explains the shape of the system, the environments you will touch, and the support boundary you are buying into. The API reference is the page you keep open in a second tab: request bodies, status codes, streaming frames, retry rules and the exact validation limits that the handlers enforce. The SMTP page covers sending infrastructure, which today means an onboarding conversation rather than a hostname you can dial. Read them in that order if you are new, and jump straight to the reference if you already know what you are calling.
Companion pages exist for software development kits and webhooks. Treat them as descriptions of the private workspace API rather than as promises about a downloadable package. A package name in a document is a dependency in someone’s lockfile; publishing a name before the registry entry exists creates install failures that look like our bug. The same logic applies to event names. A webhook catalogue is only useful if the signature scheme, the retry schedule and the replay window are all real, so the catalogue stays short until those pieces ship.
Two conventions hold across every page. First, a route is described in the present tense only when it is deployed and callable. Second, any figure or example that would require a credential you do not have is marked as private provisioning. If you spot a page that breaks either convention, that is a documentation bug worth reporting through the contact form, and it will be fixed rather than argued with.
- Docs hub — orientation, environments, support
- API reference — request and response shapes
- SMTP — onboarding shape, no live host published
- SDK pages — private workspace surface
- Webhooks — planned, signature scheme not final
Environments: local, preview, production
There are three places this code runs, and they differ in ways that matter when you are debugging. Local development runs through the Astro dev server on port 4321 with a local D1 database created from the migrations folder. Secrets come from a .dev.vars file that is never committed. Local is the only environment where you can freely break the rate-limit table, wipe contacts and replay a failed insert without anyone noticing.
Preview builds run the same Worker bundle against a preview deployment. They are useful for checking headers, redirects and the behaviour of the contact form when the database binding is absent, because that is exactly the shape of a misconfigured deployment: the page renders, the form posts, and the handler answers 503 with the word unavailable. Preview is not a sandbox for load testing. The rate limiter is shared infrastructure and the model gateway is metered.
Production is loopnow.in, served from Cloudflare’s edge with the Worker bound to the production D1 database and the production Qwen credential. Two properties of production are worth internalising before you send traffic at it. The site is statically rendered except for the two API routes and the contact page, so most requests never execute your code at all. And the chat route is public by design: there is no key to leak because there is no key to issue, which is why the per-IP limit exists.
Where credentials live, and why there is no key to copy
The question every integration guide answers first is how to authenticate, and here the honest answer is unusual: the public website API has no client credential. There is no dashboard tab that mints a token for loopnow.in, and no header you can add to a curl command to raise your limit. The chat route authenticates you to nobody because it is answering a browser on the same origin. The contact route is a form handler. Both rely on the Worker’s own bindings for anything sensitive.
That model credential is a Worker secret named QWEN_API_KEY, paired with QWEN_BASE_URL and an optional QWEN_MODEL. It is read from the cloudflare:workers environment at request time, used in an Authorization header on the server-to-server call, and never serialised into a response. If the variable is absent the route degrades to a 503 rather than falling back to an unauthenticated endpoint. Optional Cloudflare Access service token headers can be attached when the gateway sits behind Access, which keeps the origin closed to everything except this Worker.
Workspace credentials are a different category and are issued during onboarding, one workspace at a time. They are scoped to that workspace, stored as Worker secrets, and rotated by the team. They are not published here, not generated by a self-serve button, and not interchangeable with anything on this page. If a vendor asks you for a LoopNow API key and you cannot find one, that is expected: the website routes do not have one to give.
- QWEN_API_KEY — server-side secret, never returned
- QWEN_BASE_URL — gateway base, defaults to the team gateway
- QWEN_MODEL — model id, defaults to qwen36
- CF_ACCESS_CLIENT_ID / SECRET — optional service token
- IP_HASH_SALT — salts the contact rate-limit hash
A chat request, from keystroke to stream
A reader types a question into the assistant panel. The widget keeps the last twelve turns in memory, posts them to /api/chat with the current pathname, and opens a reader on the response body. On the server the handler checks the credential, parses the JSON, trims the page hint to two hundred characters, keeps the last twenty messages, and validates each content string. A failed parse or an empty array stops the request before any model call is made, which keeps malformed traffic away from the metered gateway.
If a database binding exists, the handler first increments a per-IP counter in a one-minute bucket and rejects the thirteenth attempt with 429. It then takes up to eight meaningful words from the newest message, builds a full-text query, and asks the knowledge table for up to six passages, preferring the current page and then its section. Those passages are appended to the system prompt with their URLs. Retrieval failure is caught and ignored: the request proceeds in facts-only mode instead of failing.
The model call itself is a streaming request with a low temperature, a seven-hundred token ceiling and thinking disabled, wrapped in a forty-five second timeout. The response body is piped back untouched with a no-store cache directive and buffering disabled, so the first token reaches the reader without waiting for the last. The browser reassembles frames by splitting on blank lines, reading the data prefix, parsing the JSON, and appending the delta content. A frame equal to [DONE] is ignored because the stream simply ends.
A contact submission, from form to D1
The contact page posts a normal HTML form to /api/contact with name, email, company, an intent select, a message and a consent checkbox. A honeypot input sits off-screen and is expected to stay empty. The handler detects the content type, reads either form data or JSON, and checks the honeypot before doing anything else. A filled honeypot returns the same success shape as a real submission, so an automated sender learns nothing about the trap.
Real submissions are trimmed and checked: the name must be between two and one hundred characters, the email must match a simple pattern and stay under two hundred characters, the message is truncated at five thousand, company at one hundred and twenty, phone at thirty. The intent field lands in the query_type column, defaulting to general. Consent is recorded as a version string and a timestamp only when the submitted value is on or true. The IP address is never stored raw; it is hashed with a salt and kept for rate limiting and abuse review.
If the request came from the HTML form, the handler answers with a 303 to the contact page carrying a sent or error flag, which is what makes the confirmation render without JavaScript. If the caller asked for JSON, it gets a 201 with a success boolean. Either way the row is written before the response, so a confirmation on screen means the insert succeeded. When the database binding is missing the handler returns 503, which is the single most common cause of a form that looks healthy but never delivers.
- name — 2 to 100 characters, required
- email — pattern checked, 200 character ceiling
- company_url or website — honeypot, must stay empty
- intent — stored in the query_type column
- consent — writes version and timestamp, not a boolean
Limits, allowances and the spend cap
The website endpoints have small technical limits, and the platform has commercial ones. Keep them separate. Chat allows twelve requests per IP in each fixed minute bucket, and each request may carry twenty messages of up to four thousand characters. Contact allows five submissions per hashed IP per minute. These numbers exist to stop a single script from draining a metered model or filling a sales inbox. They are not plan entitlements and they do not increase when you upgrade.
Plan allowances are a different ledger, published once in the pricing data and repeated on the pricing page. Free includes one thousand marketing contacts, five thousand emails, one hundred voice minutes, two hundred and fifty WhatsApp messages and a quarter of a million AI tokens. Growth, the most common starting point, includes twenty-five thousand contacts, one lakh emails, five thousand WhatsApp messages, fifteen hundred voice minutes, five million tokens, ten agents and fifteen seats. Prices are in rupees and exclude eighteen percent GST, which appears on the invoice rather than in the headline number.
Overage is published per meter and capped. Voice is billed at two rupees twenty per connected minute inside the allowance and two fifty on pay-as-you-go. Email is three paise per delivered message inside the allowance. A spend cap is on by default, and you choose between auto top-up and a hard stop. The important sentence for a developer is that exceeding a limit never silently bills at a worse rate than pay-as-you-go. If a campaign is about to overshoot, the cap stops it and tells you, rather than letting the invoice explain it later.
- Chat — 12 requests per IP per minute
- Contact — 5 submissions per IP per minute
- Chat payload — 20 messages, 4000 chars each
- Plan allowances — see pricing, one source of truth
- Overage — capped, never above pay-as-you-go
Errors, retries and duplicate protection
Errors from these routes are JSON with a single error string, never a stack trace and never a database message. That is deliberate: a validation error should tell you which field failed without telling an attacker how the query is built. Chat can answer 400 for a bad body, 429 for the rate limit, 503 when the credential is missing, 504 when the gateway does not answer in time and 502 when the gateway answers with a failure. Contact can answer 400 for invalid or missing fields, 429 for the limit and 503 when the database is unavailable.
Retry behaviour depends on which class you hit. A 400 will not heal; resending the same body produces the same rejection, so fix the payload. A 429 means wait until the next minute bucket rather than hammering with jittered retries, because every attempt inside the window increments the counter. A 503 caused by a missing binding will not heal by itself either. A 504 or 502 is worth one retry with a short backoff, since those reflect a transient upstream state rather than your request.
Idempotency is where the two routes diverge, and it is worth being precise because the word is often used loosely. Chat is naturally idempotent from the client’s point of view: each call regenerates an answer and nothing is stored. Contact is not. There is no idempotency key, so a retried submission creates a second row. If a form post appears to fail at the network layer but the insert succeeded, a retry produces a duplicate enquiry. That is a known trade-off; the redirect flag exists so a browser refresh shows confirmation instead of resubmitting.
Running the site locally
Local setup starts with the Node version pinned in .nvmrc, which is newer than the workstation default. Install dependencies, run the migrations against the local D1 database, seed the knowledge table, then start the dev server. The chat route needs a .dev.vars file with QWEN_BASE_URL, QWEN_API_KEY and QWEN_MODEL. Without the key the route compiles and returns 503, which is a useful way to see the degraded path before you have credentials.
One local quirk is worth knowing in advance. The Worker runtime cannot reach a Tailscale address, so a gateway that lives on a private tailnet must be proxied through localhost while you develop. That is a development convenience, not a production design: production reaches the gateway over a public hostname protected by a Cloudflare Tunnel and, optionally, an Access service token. If chat works in the browser but fails from the Worker, check the proxy before you check the model.
The verification loop is deliberately boring. Run the type check, then the build, then a preview server, and curl the root plus each API route with a known-good and a known-bad body. Watch the response headers: the chat stream should declare text/event-stream and no-store, and the contact route should redirect a form post and answer a JSON client with 201. The smoke script automates most of this, including a 404 and the sitemap, but reading one raw response by hand catches header regressions that an assertion written last quarter will not.
- nvm use — Node from .nvmrc
- npm install — install dependencies
- npm run db:migrate:local — create local tables
- npm run kb:seed — populate the knowledge index
- npm run dev — http://127.0.0.1:4321
- .dev.vars — local secrets, never committed
Support boundaries and escalation
Support is split by question type, and knowing the split saves a round trip. Questions about an integration you are building against a private workspace go to the team that provisioned it, through the same thread that issued the credentials. Questions about the public website routes, this documentation or a broken example go through the contact form with the intent set to the closest match. Security reports have a separate path and should not wait in a sales queue.
Response expectations differ by plan and are published on the pricing page rather than restated here: community for Free, email within a day for Starter, four hours for Growth, and round-the-clock cover with a named contact for Scale and Enterprise. No self-serve plan publishes an SLA. The status page at /status/ records incidents and is the first place to check before filing a report, because a known incident saves everyone a debugging session.
That last point is intentionally unglamorous. An SLA claim on a marketing page is worth less than a record you can read after something breaks, and an incident history is the only evidence a prospect can actually verify. If uptime is a contractual requirement for your project, it belongs in an Enterprise agreement with named terms, not in an inference from a sentence on this page.
The fastest way to get a useful answer is to include the request, the response status, the response body and the timestamp in IST. Do not include a secret, a full API key or a customer’s personal data. If the issue is a 503 on chat, say whether the deployment has the model credential bound; if it is a contact form that never confirms, say whether the database binding exists. Those two facts resolve the majority of reports before anyone opens a dashboard.
How to read a page marked live, private or planned
Three labels carry the whole documentation contract. Live means the behaviour is deployed, callable today and covered by a handler in this repository. Private means it exists for a provisioned workspace but is not published as a public interface, so the page describes the shape without pretending you can call it from anywhere. Planned means the design is written down and the code is not, and nothing on the page should be treated as a commitment to a date.
The labels are not marketing hedges. They exist because the alternative, a single confident reference that mixes all three, produces integrations that fail in ways the reader cannot diagnose. A webhook receiver built against an event name that never fires is worse than no receiver at all, because it looks finished. The same is true of an SDK import that resolves in a document and fails in a terminal. When in doubt, the label on the heading is the answer, and a page without a label is describing something live.
If you are evaluating LoopNow for a build, read the API reference first and the SMTP page second. Between them they tell you what can be wired up this week and what needs an onboarding call. If the answer is that your use case needs the private workspace surface, ask for it explicitly and describe the volume you expect, because provisioning is a manual step with a real queue. That is a slower answer than a fake endpoint, and it is the one that survives contact with production.
Frequently asked questions
Do I need an API key to call /api/chat?
No. The route is same-origin and public, so there is no client credential to send and no header that changes the response. The model credential lives in a Worker binding named QWEN_API_KEY and is used only for the server-to-server call. Protection comes from a twelve requests per minute per IP limit and from the fact that the handler rejects malformed bodies before spending any tokens.
Why does chat return 503 instead of an answer?
The handler checks for QWEN_API_KEY before it parses anything and returns 503 with a message pointing at the contact form when the binding is missing. That is a deployment state, not a bug in your request. It usually means the environment was created without secrets, which is common on preview deployments and local machines that have no .dev.vars file yet.
Can I call these endpoints from another domain?
Not from a browser. Neither route emits CORS headers, so a cross-origin fetch will be blocked by the browser before your code sees a response. Server-side callers such as curl are not subject to that restriction, but the routes are still intended for the loopnow.in front end. If you need a server integration, ask about the private workspace API during onboarding.
What happens to my chat messages after the stream ends?
Nothing is persisted by the chat route. Messages arrive in the request body, are trimmed to the last twenty, are used to build the prompt and are then discarded; the response is streamed and not stored. The client keeps its own short history in memory. The database is used for rate-limit counters and for reading the knowledge index, not for writing conversations.
Is the contact form idempotent?
No. There is no idempotency key and no uniqueness constraint on email, so sending the same details twice creates two rows. The HTML form flow mitigates the common case by redirecting to a confirmation URL, which stops a refresh from resubmitting. If you are building an automated caller, treat a timeout as unknown rather than failed and check before retrying.
How is the contact rate limit calculated if IPs are not stored?
The address is hashed with SHA-256 using a salt from the IP_HASH_SALT binding, and only the hex digest is written. The bucket key is the digest, so the limiter can count five attempts per minute without retaining the raw address. The same digest is stored on the contact row for abuse review, which is why the salt matters: without it, hashes of a small IPv4 space are trivially reversible.
Does the site work without JavaScript?
Yes for content and for the contact form. Pages are rendered on the server and the form posts normally, receiving a redirect back to a confirmation state. The assistant panel needs JavaScript because streaming requires a reader on the response body, so on a no-JavaScript client the chat panel is simply unavailable and the contact page remains the path to a human.
Where do I report a documentation error?
Use the contact form and say which page and which sentence is wrong. Documentation fixes are treated as ordinary defects rather than suggestions, because an inaccurate reference costs more than a missing one. If the error involves a security property, for example a page implying a credential is safe to expose, report it through the security contact instead of the general form.
Are there SDKs I can install today?
No published packages. The SDK pages describe the private workspace API, which is provisioned per workspace with scoped keys. Publishing an install command before the registry entry exists would break builds, so the documentation says plainly that access is issued during onboarding. When a package is published, the version and the install command will appear on those pages at the same time.