Skip to main content

Deleting Submissions By Token

Freeform allows users to delete their own submissions securely using a unique token associated with each submission. This is especially useful when you want to include a Delete my submission or Withdraw my entry link inside an email notification sent to the user after form submission.

How It Works

Every Freeform submission includes a unique token (submission.token) that can be used to identify it without requiring the user to log in. You can pass this token as part of a URL to a front-end template that handles the deletion logic.

Tokens are automatically generated securely and unique per submission. There's no need for user authentication if the token is only shared privately (e.g., in an email sent to that user).

Once deleted, the submission and its token are no longer valid.

Example

For example, inside an email notification, you could include a link to a template that contains the logic to delete the submission when visited:

Email Notification Template
<p>If you wish to remove your submission, click the link below:</p>
<p><a href="https://example.com/submission/delete/{{ submission.token }}">
Delete My Submission
</a></p>

The template located at /submissions/delete would contain the following logic:

/submissions/delete.twig
{% set token = craft.app.request.segment(3) %}

{% if freeform.deleteSubmissionByToken(token) %}
<p>✅ Submission removed successfully.</p>
{% else %}
<p>⚠️ Nothing to remove or invalid token.</p>
{% endif %}

Adjust the segment number for craft.app.request.segment(3) depending on your URL pattern.

You can customize the success and failure messages, or redirect users instead of displaying text directly:

/submissions/delete.twig
{% set token = craft.app.request.segment(3) %}

{% if freeform.deleteSubmissionByToken(token) %}
{% redirect '/thank-you/deleted' %}
{% else %}
{% redirect '/error/invalid-token' %}
{% endif %}
Page Feedback