Skip to content
Lazyform
Docs menu

Getting started

Responses and errors

What the endpoint sends back on success and failure, in JSON and for plain HTML forms, and every error code explained.

The endpoint answers in one of two ways, depending on how the form was sent.

  • JSON, when the request asks for it: an Accept: application/json header, or a JSON body.
  • A redirect (303) for everything else, which is what a plain HTML form gets: to your thank-you page on success, or to a friendly error page when something's wrong.

Success

json
{ "success": true, "message": "Submission received.", "id": "sub_…" }

The status is 200. The id matches the submission in your dashboard.

A plain HTML form is redirected to the redirect field if you sent one, else to the redirect set in the form's settings, else to our thank-you page.

Submissions our checks consider spam get the same success answer. That's on purpose: bots learn nothing. The submission is kept in your Spam folder, where you can restore it.

Errors

Errors have a stable code you can check in code, and a message written for people:

json
{
  "success": false,
  "error": {
    "code": "invalid_access_key",
    "message": "No form has this access key."
  }
}

A plain HTML form is redirected to /submit-error?code=<code>, a page that explains the problem to the visitor and has a link back to your form.

Error codes

Status Code When
400 missing_access_key No key in the body or the URL
400 invalid_body The body couldn't be read (for example broken JSON)
400 empty_submission No fields besides the special ones
400 invalid_email Email validation is on and refused the address
400 invalid_phone Phone validation is on and refused the number
400 disposable_email The throwaway email filter is on and refused the address
400 captcha_failed The captcha token is missing or invalid
400 file_not_allowed A file type isn't allowed, or uploads are off
400 file_too_large A file is over the size limit
400 too_many_files More files than the form allows
403 domain_not_allowed Allowed websites is on and the page isn't listed
403 country_not_allowed The country filter refused it
404 invalid_access_key No form has this key
409 form_paused You paused the form
413 payload_too_large The request is over the size limit
423 account_suspended The account is suspended for abuse
429 rate_limited Too many submissions from this visitor or to this form

How to fix each error

missing_access_key

Add <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY"> inside the <form>, or post to https://lazyform-api.xvelopers.com/f/YOUR_ACCESS_KEY. With JSON, include "access_key" in the body.

invalid_body

We couldn't read the request. Send a normal form post, multipart/form-data or a JSON object (not an array or a string), and check that JSON bodies are valid, for example with JSON.stringify.

empty_submission

Only special fields arrived. Check that your inputs have a name attribute: inputs without a name are never sent by the browser.

invalid_email

The email validation feature checked the address and it can't receive mail. Ask the visitor to check it, or turn the feature off.

invalid_phone

The phone validation feature refused the number. Ask for numbers with a country code, or set the default country in the form's settings.

disposable_email

The visitor used a throwaway address. Ask them for a real one, or turn off the throwaway email filter.

captcha_failed

The form has a captcha connected but the token was missing or wrong. Make sure the captcha widget is inside the <form> and that the site key on the page and the keys in the integration belong together. See Turnstile, hCaptcha or reCAPTCHA v2 and v3.

file_not_allowed

Uploads are off for this form, or the file's type isn't in the allowed list. See file uploads.

file_too_large

A file is bigger than the form's limit (25 MB at most).

too_many_files

More files were sent than the form allows (5 at most).

domain_not_allowed

Allowed websites is on and the request came from a page that isn't on the list. Add the domain in the form's settings. Testing locally? Add localhost too.

country_not_allowed

The country filter is on and refused the visitor's country.

invalid_access_key

No form has this key. Copy it again from the dashboard; it starts with lf_.

form_paused

You paused the form in the dashboard. Resume it to accept submissions again.

payload_too_large

The request is over 100 KB (no files) or 30 MB (with files). Very long text fields or big files are the usual cause.

account_suspended

The account was suspended under our acceptable use policy. Email us if you think it's a mistake.

rate_limited

Too many submissions from one visitor or to one form in a short time. Real visitors rarely hit this; wait a minute and try again.

Handling responses in code

js
const res = await fetch('https://lazyform-api.xvelopers.com/submit', {
  method: 'POST',
  headers: { Accept: 'application/json' },
  body: new FormData(form),
})
const result = await res.json()

if (result.success) {
  showThanks()
} else if (result.error.code === 'rate_limited') {
  showError('Please wait a minute and try again.')
} else {
  showError(result.error.message)
}