Forms Intake Recipe
An end-to-end recipe for submitting forms to the Merion API from a server-side Node.js or TypeScript context — full working code, error handling, and gotchas.
Scenario
You want to embed a Merion form — for example, a Refer a Debt form — in your own web application and submit it to the Merion API on behalf of the user. This recipe covers server-side submission from Node.js or a compatible edge runtime (Vercel Edge Functions, Cloudflare Workers, AWS Lambda).
Before you start
- Submit from server-side, not the browser. The public forms endpoint
does not require authentication, but server-side submission avoids CORS issues
(Merion's CORS policy allows
*.merion.com.auorigins only — see Getting Started) and gives you a clean place to add your own validation before hitting the Merion API. - Validate on your side too. Merion will return field errors if server-side validation fails, but providing good client-side and server-side validation in your own application means users see faster, friendlier error messages.
- Coordinate before volume testing. Merion does not currently offer a sandbox endpoint. Email [email protected] before running automated volume tests.
Step 1 — collect and validate the form data
Use your own form, your own validation. The fields required depend on the form key — see Forms API for the full field reference per key. Validate required fields, email formats, and any business rules before submitting to Merion.
Step 2 — submit to Merion
// TypeScript — Node.js / edge function context
const MERION_API = "https://api.merion.com.au";
async function submitToMerion(
formKey: string,
fields: Record<string, string>
): Promise<{ ok: boolean; error?: string }> {
const res = await fetch(`${ MERION_API }/public/forms/${ formKey }`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ form: formKey, fields, hp: "" }),
});
if (res.ok) {
return { ok: true };
}
const body = await res.json().catch(() => ({}));
return { ok: false, error: body?.message ?? `HTTP ${ res.status }` };
}
// Usage — refer-a-debt form
const result = await submitToMerion("refer-a-debt", {
creditor_name: "Acme Pty Ltd",
creditor_email: "[email protected]",
creditor_phone: "0412 345 678",
debtor_name: "Slow Payer Pty Ltd",
debtor_contact: "[email protected]",
amount: "12500.00",
description: "Outstanding invoices INV-001 through INV-004",
});
if (!result.ok) {
console.error("Submission failed:", result.error);
} Step 3 — handle the response
- On success (
result.ok === true): show the user a confirmation message. Do not re-submit. The record is now in Merion's system. - On a 400 or 422 error: surface the
result.errormessage to the user or administrator. Fix the payload — do not retry automatically, as the same error will occur. - On a 500 or 503 error: retry with exponential backoff. See Error Handling for a retry recipe.
Honeypot field
Always include "hp": "" in the payload — an empty string, never a non-empty value.
The honeypot field is a spam-prevention mechanism. If the hp value is non-empty,
Merion discards the submission silently (returns a success response, but the record is not stored).
If your frontend form includes a visible hp input, ensure it is hidden via CSS
and that no autofill or autocomplete populates it. Do not pre-fill it in your server-side code.
Logging
- Log the submission attempt (form key, timestamp, your internal reference ID if applicable).
- Log the API response status code.
- Do not log the full request payload in production — it may contain PII (debtor names, emails, financial amounts). Log only what you need for debugging.
- Do not log Bearer tokens if you add authenticated calls later.
Idempotency note
The forms endpoint is not idempotent — submitting the same data twice creates two records.
If your workflow might retry on network failure, track submitted requests in your own
database (e.g., store a submitted_at timestamp against the user's session)
and skip re-submission if the record already exists.
Available form keys
For the full list of available form keys and their required fields, see
Forms API. Current keys include:
contact, refer-a-debt, request-a-quote,
partner-referral, become-a-partner.
Ready to integrate with Merion?
API access is available to approved partners and integrators. Contact us to start the conversation — no commitment required.