Skip to content

API Reference

Terminal window
npm install @formtress/js

Current version: 1.0.0

Submits form data to the Formtress endpoint.

import { submitForm } from '@formtress/js'
const result = await submitForm({
url: 'https://app.formtress.com/api/f/your-form-id',
data: new FormData(formElement),
})
NameTypeRequiredDescription
optionsobjectYesSubmission options.
options.urlstringYesThe form’s submit URL (https://app.formtress.com/api/f/your-form-id). Typically read from form.action.
options.dataFormDataYesA FormData instance containing the fields to submit.

Returns Promise<SubmitResult>.

interface SubmitResult {
ok: boolean
message?: string
status?: number
}
FieldTypeDescription
okbooleantrue if the submission was accepted and passed validation.
messagestring | undefinedError message from the server. Only present when ok is false.
statusnumber | undefinedHTTP status code from the server.

The Webflow script progressively enhances standard HTML forms that submit directly to Formtress. Forms work without JavaScript — the script adds Webflow’s native success/error states and loading text support.

https://cdn.jsdelivr.net/npm/@formtress/js@1.0.0/dist/js/webflow.js
  1. On DOMContentLoaded, finds all <form> elements whose action points to the Formtress submit endpoint.
  2. Attaches a submit handler to each form.
  3. Intercepts and prevents the default form submission.
  4. Collects form data and sends it to the form’s action URL via fetch.
  5. On success: triggers Webflow’s native success state.
  6. On error: triggers Webflow’s error state and updates any data-ft-error element.
  7. Without the script: the form submits normally via standard HTML — spam protection still runs server-side.

Always pin to a specific version in production:

<script src="https://cdn.jsdelivr.net/npm/@formtress/js@1.0.0/dist/js/webflow.js"></script>

To get the latest version automatically (not recommended for production):

<script src="https://cdn.jsdelivr.net/npm/@formtress/js@latest/dist/js/webflow.js"></script>

Terminal window
npm install @formtress/server

Current version: 0.1.0

The raw HTTP endpoint behind @formtress/server. No data is stored — this endpoint only returns a spam score.

HeaderRequiredDescription
AuthorizationYesBearer ftk_<your-api-key>
Content-TypeYesapplication/json
{
"ip": "1.2.3.4",
"headers": Object.fromEntries(request.headers),
"fields": [
{ "name": "email", "value": "test@gmail.com", "type": "email" },
{ "name": "message", "value": "Hello world", "type": "text" }
],
"blockFreeEmailProviders": true
}
FieldTypeRequiredDescription
ipstringYesEnd-user’s IP address (used for rate limiting).
headersRecord<string, string>YesForwarded request headers from the end-user’s browser.
fieldsArray<{ name, value, type }>NoField values for content-level spam detection.
blockFreeEmailProvidersbooleanNoFlag free email providers (e.g. gmail.com) as spam. Defaults to false.
{
"isSpam": true,
"score": 0.85,
"rateLimited": false,
"fieldErrors": {
"email": "spam detected"
}
}
FieldTypeDescription
isSpambooleanWhether the submission was detected as spam.
scorenumberSpam confidence score (0–1).
rateLimitedbooleanWhether the end-user was rate limited.
fieldErrorsRecord<string, string>?Per-field spam errors (only present if fields were flagged).
{ "error": "Invalid or missing API key" }
{
"error": "Invalid request body",
"issues": { ... }
}
https://app.formtress.com/public/api/v1/filter