Skip to content

Snaptcha FreeForm integration - AJAX resubmission fails even with One Time Key disabled #5

@shgzon

Description

@shgzon

Environment

  • Craft CMS Pro 5.8.17
  • Freeform 5.12.2
  • Snaptcha latest version
  • Tailwind 4 Freeform formatting template

Description

I’m integrating Snaptcha with Freeform. The hidden input field renders correctly ({{ craft.snaptcha.field }}), and the first AJAX form submit works fine.
But when I submit the form again via AJAX (without reloading the page), I consistently get a 400 (Bad Request) error.

POST ... 400 (Bad Request)
Uncaught (in promise) Error: Request failed with status

Expected Behavior

  • With One Time Key disabled, I would expect the Snaptcha field to still be valid for multiple submissions until it expires (Expiration Time = 60 minutes).
  • A second AJAX submit should succeed without requiring a reload.

Steps to Reproduce

  1. Render Freeform form with {{ craft.snaptcha.field }}.
  2. Submit once via AJAX → works.
  3. Submit again via AJAX (same page, same form) → 400 error.

Notes

  • With non-AJAX forms, multiple submissions do work as expected when One Time Key is disabled.
  • This suggests the hidden input is being consumed or invalidated after the first AJAX submission.
  • Should AJAX workflows fetch a fresh field via /actions/snaptcha/field/get-field after each submit? Or should the same field value remain valid when One Time Key is off?

Looking for clarification on whether this is intended behavior or if it’s a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions