Forms API

Forms API Recipes

End-to-end worked examples for every public form key — curl, JavaScript fetch, and error handling patterns for each.

All five form keys share the same endpoint shape and response envelope. Read the Forms API reference for the full field definitions. The examples below show the minimum valid payload for each key, plus a JavaScript fetch wrapper you can adapt.

Request and response envelope diagram for the Forms API
Every form key uses the same JSON request shape and returns the same data/error envelope.

Shared fetch helper

This helper handles the JSON envelope, the honeypot field, and surfaces validation errors to your UI. Use it across all five key examples below.

async function submitMerionForm(key, fields) {
  const res = await fetch(
    `https://api.merion.com.au/public/forms/${key}`,
    {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ form: key, fields, hp: "" }),
    }
  );

  const json = await res.json();

  if (!res.ok || json.error) {
    // Throw with field-level details so the UI can show inline errors.
    const err = json.error ?? { code: "UNKNOWN", message: "Unexpected error" };
    const e = new Error(err.message);
    e.code = err.code;
    e.details = err.details ?? ;
    throw e;
  }

  return json.data; // { message, redirect? }
}

contact — General enquiry

Use this key for the general contact form at merion.com.au/contact-us/.

curl

curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "form": "contact",
    "fields": {
      "name":    "Jane Smith",
      "email":   "[email protected]",
      "phone":   "0400 000 000",
      "message": "I would like to enquire about commercial debt recovery services for my business."
    },
    "hp": ""
  }' \
  https://api.merion.com.au/public/forms/contact

JavaScript

const result = await submitMerionForm("contact", {
  name:    "Jane Smith",
  email:   "[email protected]",
  phone:   "0400 000 000",
  message: "I would like to enquire about commercial debt recovery services.",
});

console.log(result.message);   // "Thank you. We will be in touch shortly."
if (result.redirect) window.location.href = result.redirect;

Required fields

name
Required. Full name of the enquirer.
email
Required. Valid email address.
message
Required. Minimum 10 characters.
phone
Optional.

refer-a-debt — Refer an overdue account

Use this key when a creditor wants to refer a specific overdue debt to Merion for recovery.

curl

curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "form": "refer-a-debt",
    "fields": {
      "name":        "Alex Brown",
      "email":       "[email protected]",
      "company":     "My Business Pty Ltd",
      "debtor_name": "Debtor Co Pty Ltd",
      "amount":      "12500",
      "notes":       "Invoice #INV-0042, 90 days overdue. Debtor has been contacted twice."
    },
    "hp": ""
  }' \
  https://api.merion.com.au/public/forms/refer-a-debt

JavaScript

const result = await submitMerionForm("refer-a-debt", {
  name:        "Alex Brown",
  email:       "[email protected]",
  company:     "My Business Pty Ltd",
  debtor_name: "Debtor Co Pty Ltd",
  amount:      "12500",
  notes:       "Invoice #INV-0042, 90 days overdue.",
});

Required fields

name
Required. The creditor's full name.
email
Required. The creditor's email address.
company
Required. The creditor's business name.
debtor_name
Required. Name of the debtor business or person.
amount
Required. Approximate amount owed in AUD (string, no currency symbol needed).
notes
Optional. Additional context — invoice numbers, prior contact history.

request-a-quote — Quote before committing

Use this key when a creditor wants a commission estimate before formally referring a debt.

curl

curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "form": "request-a-quote",
    "fields": {
      "name":        "Sam Taylor",
      "email":       "[email protected]",
      "company":     "Taylor Trades Pty Ltd",
      "debt_amount": "8500",
      "debt_age":    "120 days"
    },
    "hp": ""
  }' \
  https://api.merion.com.au/public/forms/request-a-quote

JavaScript

const result = await submitMerionForm("request-a-quote", {
  name:        "Sam Taylor",
  email:       "[email protected]",
  company:     "Taylor Trades Pty Ltd",
  debt_amount: "8500",
  debt_age:    "120 days",
});

Required fields

name
Required. Full name.
email
Required. Contact email.
debt_amount
Required. Approximate debt value in AUD.
company
Optional. Business name.
debt_age
Optional. How long overdue, e.g., "90 days".

partner-referral — Referral from a partner account

This key is for partners in the Merion Partner Programme submitting a referral on behalf of one of their clients. It captures both the partner's details and the end client's details.

curl

curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "form": "partner-referral",
    "fields": {
      "partner_name":   "Metro Accounting Group",
      "partner_email":  "[email protected]",
      "client_name":    "Widget Wholesale Pty Ltd",
      "client_email":   "[email protected]",
      "debtor_name":    "Slow Pay Co Pty Ltd",
      "amount":         "23000",
      "notes":          "Client instructed us to refer. Two letters of demand already sent."
    },
    "hp": ""
  }' \
  https://api.merion.com.au/public/forms/partner-referral

JavaScript

const result = await submitMerionForm("partner-referral", {
  partner_name:   "Metro Accounting Group",
  partner_email:  "[email protected]",
  client_name:    "Widget Wholesale Pty Ltd",
  client_email:   "[email protected]",
  debtor_name:    "Slow Pay Co Pty Ltd",
  amount:         "23000",
  notes:          "Two letters of demand already sent.",
});

Required fields

partner_name
Required. Partner business or individual name.
partner_email
Required. Partner contact email.
client_name
Required. End client business name.
client_email
Required. End client contact email.
debtor_name
Required. Debtor business or person name.
amount
Required. Approximate amount owed in AUD.
notes
Optional. Any additional context.

become-a-partner — Apply for the Partner Programme

Use this key for the partner programme application form. Suitable for accountants, bookkeepers, business advisers, and legal professionals who want to refer clients to Merion on a commission basis.

curl

curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "form": "become-a-partner",
    "fields": {
      "name":    "Chris Wong",
      "email":   "[email protected]",
      "company": "CW Accounting Pty Ltd",
      "role":    "Accountant",
      "message": "I advise around 40 SME clients and frequently encounter slow-paying debtors. I would like to refer appropriate clients to Merion."
    },
    "hp": ""
  }' \
  https://api.merion.com.au/public/forms/become-a-partner

JavaScript

const result = await submitMerionForm("become-a-partner", {
  name:    "Chris Wong",
  email:   "[email protected]",
  company: "CW Accounting Pty Ltd",
  role:    "Accountant",
  message: "I advise around 40 SME clients and frequently encounter slow-paying debtors.",
});

Required fields

name
Required. Full name.
email
Required. Contact email.
company
Required. Business name.
role
Optional. Role or profession, e.g., "Bookkeeper".
message
Optional. Why you would like to partner with Merion.

Error handling recipe

The API returns a consistent error envelope for all validation failures. Here is a complete pattern for rendering field-level errors in a form:

async function handleFormSubmit(key, fields, form) {
  // Clear any prior errors
  form.querySelectorAll(".field-error").forEach(el => el.remove());

  try {
    const data = await submitMerionForm(key, fields);
    showSuccessMessage(data.message);
    if (data.redirect) window.location.href = data.redirect;
  } catch (err) {
    if (err.code === "VALIDATION_ERROR" && err.details) {
      // Show inline errors per field
      for (const [field, msg] of Object.entries(err.details)) {
        const input = form.querySelector(`[name="${field}"]`);
        if (input) {
          const hint = document.createElement("p");
          hint.className = "field-error";
          hint.textContent = msg;
          input.after(hint);
        }
      }
    } else if (err.code === "RATE_LIMITED") {
      showError("Too many submissions — please wait a moment and try again.");
    } else {
      showError(err.message ?? "Something went wrong. Please try again.");
    }
  }
}

For rate-limit and server-error handling at the network level, see Errors & Rate Limits.

Get started

Ready to integrate with Merion?

API access is available to approved partners and integrators. Contact us to start the conversation — no commitment required.