Skip to content

docs: Document HTTP 409 response when deleting fields in use by Segments#295

Open
promptless-for-oss wants to merge 2 commits intomautic:5.xfrom
Promptless:promptless/pr-15882-field-delete-error
Open

docs: Document HTTP 409 response when deleting fields in use by Segments#295
promptless-for-oss wants to merge 2 commits intomautic:5.xfrom
Promptless:promptless/pr-15882-field-delete-error

Conversation

@promptless-for-oss
Copy link

Open this suggestion in Promptless to view citations and reasoning process

Adds documentation to the Fields API delete endpoint explaining that attempting to delete a field that's in use by a Segment returns an HTTP 409 (Conflict) response. This behavior was added to make the API consistent with the Mautic UI, which already prevents deletion of fields in use by Segments.

Trigger Events

mautic/mautic PR #15882: Prevent deletion of custom fields if they are in use by segments via API

Promptless Research (1 GitHub PR)

Agent Response

I've completed the documentation update for PR #15882. Here's a summary of what I did:

Summary

PR #15882 adds validation to the Fields REST API to prevent deletion of custom fields that are in use by Segments. Previously, the API allowed deletion even when fields were being used (inconsistent with the UI behavior).

Documentation Changes

I created a suggestion that updates the Delete field section of the Fields API documentation (docs/rest_api/fields.rst) to document:

  1. A note explaining that fields in use by Segments cannot be deleted via the API
  2. The HTTP 409 (Conflict) response code that the API now returns in this scenario
  3. Guidance to remove the field from Segment filters before attempting deletion

The changes follow the existing documentation style and patterns used throughout the REST API docs.

Suggestion Created

Document HTTP 409 response when deleting fields in use by Segments

This suggestion is ready for your review.


Tip: Attach PDFs in Slack messages to Promptless—it can even extract images from them 📎

Signed-off-by: promptless-for-oss <promptless-for-oss@users.noreply.github.com>
@promptless-for-oss promptless-for-oss requested a review from a team as a code owner February 24, 2026 18:31
@promptless-for-oss promptless-for-oss requested review from adiati98 and favour-chibueze and removed request for a team February 24, 2026 18:31

``DELETE /fields/contact/ID/delete`` or ``DELETE /fields/company/ID/delete``

.. note::
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Citation: Based on PR #15882 which adds HTTP 409 (Conflict) response to the API when trying to delete custom fields that are in use by segments. The key changes are in app/bundles/ApiBundle/Controller/CommonApiController.php which now catches DeleteEntityDependencyException and returns 409, and app/bundles/LeadBundle/Field/EventListener/LeadFieldSubscriber.php which checks for segment dependencies.
View source

@RCheesley
Copy link
Member

This PR will need to be rebased onto the 7.1 branch once it's created.

Signed-off-by: promptless-for-oss <promptless-for-oss@users.noreply.github.com>
@promptless-for-oss
Copy link
Author

I've added new changes to address this PR review in commit ab1c863

@promptless-for-oss
Copy link
Author

I've processed your request, but no documentation changes were needed.

Copy link
Member

@fedys fedys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@promptless-for-oss
Copy link
Author

Promptless escalated the following message to you. If you respond, please remember to tag Promptless:

I reviewed PR #295 and found that RCheesley's feedback has already been addressed:

  1. Text suggestion ✅ - The note already uses the exact wording suggested: "You can't delete a field that's in use by a Segment. This returns an HTTP 409 (Conflict) response. Remove the field from any Segment filters before deleting it."

  2. Rebase onto 7.1 branch ⏳ - This can't be done yet because the 7.1 branch doesn't exist. RCheesley noted it will need to happen "once it's created." The "needs-rebase" label is essentially a reminder for when that branch is available.

No further changes are needed at this time. I'll handle the rebase when the 7.1 branch is created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants